#include using namespace std ; bool capitalLetter ( const char * s ) { int i ; int n = strlen( s ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( 'A' <= s[i] && s[i] <= 'Z' ) continue ; return 0 ; } return 1 ; } bool onlyNumber ( const char * s , bool caseB ) { int n = strlen ( s ) ; for ( int i = 0 ; i < n ; ++ i ){ if( s[ i ] - 48 <= 9 && s[ i ] - 48 >= 0 ) continue ; return 0 ; } if( ( n == 2 || n == 3 ) && caseB ) return 1 ; else if ( n!=2 && !caseB ) return 0 ; return 1 ; } int main() { //freopen("input.in" , "r" , stdin ) ; int quest ; scanf("%i" , &quest ) ; cin.ignore() ; while( quest -- ) { char buffer [ 30 ] ; gets( buffer ) ; char s[20][20] ; int is = 0 ; istringstream ss ( buffer ) ; int sum = 0 ; while( ss >> s [ is ] ){ sum += strlen(s[is]) ; ++ is ;} /* s[0] s[1] s[2] */ bool ok = true ; ok &= ( strlen(buffer) == ( sum + 2 ) ) ; bool caseB ; if( strcmp(s[0] , "B") == 0 ) caseB = true ; else { caseB = false ; ok &= capitalLetter( s[ 0 ]) ; } ok &= onlyNumber( s [ 1 ] , caseB ) ; ok &= capitalLetter(s [ 2 ] ) ; //cout << caseB << '\n' ; std::cout << ( ( ok ) ? "Correct!\n" : "Incorrect!\n" ) ; } return 0 ; } /* *************************************************************************************************************** 1) First of all, the first character group can be either the character "B" (not "b") or any group of 2 capital letters from the English alphabet. 2)The second group can only contain digits (0-9). Moreover, there must be exactly 2 digits in this group. The only exception is when the first group is B, in which case this group can contain either 2 or 3 digits. 3)The last character group should always contain 3 capital letters, regardless of the values in the first 2 groups. */