Advertisement
Malinovsky239

Untitled

Oct 26th, 2011
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <string>
  4. #include <cctype>
  5.  
  6. using namespace std;
  7.  
  8. string ex = "ABCEHKMOPTXY";
  9.  
  10. bool check(char c) {
  11.     for (int i = 0; i < ex.size(); i++)
  12.         if (ex[i] == c)
  13.             return true;
  14.     return false;                  
  15. }
  16.  
  17. int main() {
  18.     freopen("input.txt", "r", stdin);
  19.     freopen("output.txt", "w", stdout);
  20.  
  21.     int n;
  22.     cin >> n;
  23.  
  24.     for (int i = 0; i < n; i++) {
  25.         string s;
  26.         cin >> s;
  27.         bool ok = true;
  28.  
  29.         if (s.size() != 6)
  30.             ok = false;
  31.         else {
  32.             for (int i = 1; i < 4; i++)
  33.                 if (!isdigit(s[i]))
  34.                     ok = false;
  35.  
  36.             if (!check(s[0]) || !check(s[4]) || !check(s[5]))
  37.                 ok = false;
  38.         }
  39.  
  40.         if (ok)
  41.             puts("Yes");
  42.         else
  43.             puts("No");
  44.     }
  45.  
  46.     return 0;
  47. }
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement