Valid ID

  1. Suppose we want to test whether an input string matches the following rules:
    1. String length is 10.
    2. The first character is an uppercase letter.
    3. The second character is either '1' or '2'.
    4. The remaining 8 digits can be among '0' ~ '9'.
  2. Write a function to test a string.
    int main()
    {
        string s;
        while (cin >> s)
        {
            if (valid_id(s))
                cout << s << " is valid.\n";
            else
                cout << s << " is NOT valid.\n";
        }
        return 0;
    }  
  3. You may test your program with these data.