Legal identifier of C Language
Legal identifier of C Language
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 44597 Accepted Submission (s): 17933
Problem Description input a string to determine whether it is a legal identifier of C.
The Input data contains multiple test instances. The first line of the data is an integer n, indicating the number of test instances, followed by n rows of Input data, each line is a string of no more than 50 characters.
Output outputs a row of input data for each group. If the input data is a valid identifier of C, "yes" is output; otherwise, "no" is output ".
Sample Input
312ajffi8x_aff ai_2
Sample Output
noyesno
# Include
# Include
Main ()
{Int a, I, j, B;
Char s [100];
Scanf ("% d", & B );
Getchar ();
While (B --)
{A = 1;
Gets (s );
If (s [0] <'A' & s [0]> 'Z') & (s [0]! = '_') | S [0] <'A' | s [0]> 'Z ')
{
Printf ("no \ n ");
Continue;
}
J = strlen (s );
For (I = 1; I If (s [I]> = 'A' & s [I] <= 'Z ') | (s [I]> = '0' & s [I] <= '9 ') | (s [I]> = 'A' & s [I] <= 'Z') | (s [I] = '_'))
A ++;
If (a = j)
Printf ("yes \ n ");
Else
Printf ("no \ n ");
}
Return 0;
}