tuttelikz

#691 - Номера автобусов [+]

Feb 14th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <cstdio>
  6. #include <math.h>
  7. #include <string>
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <string>
  11. #include <stdlib.h>
  12. #include <cmath>
  13. #include <iomanip>
  14. #include <fstream>
  15.  
  16. using namespace std;
  17.  
  18. bool checkLetter(char a) {
  19.     if (a == 'A' || a == 'B' || a == 'C' || a == 'E' || a == 'H' || a == 'K' || a == 'M' || a == 'O' || a == 'P' || a == 'T' || a == 'X' || a =='Y') {
  20.         return true;
  21.     }
  22.     else {
  23.         return false;
  24.     }
  25. }
  26.  
  27. bool checkDigit(char b) {
  28.     if (b == '1' || b == '2' || b == '3' || b == '4' || b == '5' || b == '6' || b == '7' || b == '8' || b == '9' || b == '0') {
  29.         return true;
  30.     }
  31.     else {
  32.         return false;
  33.     }
  34. }
  35.  
  36. int main(int argc, const char * argv[]) {
  37.     int numberTests;
  38.     cin>>numberTests;
  39.     string regNumbers[55];
  40.     for (int i=0; i<numberTests; i++) {
  41.         cin>>regNumbers[i];
  42.     }
  43.    
  44.     for (int i=0; i<numberTests; i++) {
  45.         if (regNumbers[i].length() == 6 && checkLetter(regNumbers[i].at(0)) && checkDigit(regNumbers[i].at(1)) && checkDigit(regNumbers[i].at(2)) && checkDigit(regNumbers[i].at(3)) && checkLetter(regNumbers[i].at(4)) && checkLetter(regNumbers[i].at(5))) {
  46.             cout<<"Yes"<<endl;
  47.         }
  48.         else {
  49.             cout<<"No"<<endl;
  50.         }
  51.     }
  52.    
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment