[Plain] Description
Enter a string to check whether it is a valid identifier of C.
Input
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
Output 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
3
12ajf
Fi8x_a
Ff ai_2
Sample Output
No
Yes
No
Description
Enter a string to check whether it is a valid identifier of C.
Input
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
Output 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
3
12ajf
Fi8x_a
Ff ai_2
Sample Output
No
Yes
No
[Plain] # include <stdio. h>
# Include <string. h>
Int main ()
{
Int I;
Int flag;
Int num;
Int length;
Char string [101];
Scanf ("% d", & num );
Getchar ();
While (num --)
{
Gets (string );
Length = strlen (string );
Flag = 1;
If (string [0] = '_' | (string [0]> = 'A' & string [0] <= 'Z ') | (string [0]> = 'A' & string [0] <= 'Z '))
{
For (I = 0; I <length; I ++)
{
If (string [I] = '_' | (string [I]> = 'A' & string [I] <= 'Z ') | (string [I]> = 'A' & string [I] <= 'Z ') | (string [I]> = '0' & string [I] <= '9 '))
{
Flag = 1;
}
Else
{
Flag = 0;
}
If (flag = 0)
{
Break;
}
}
}
Else
{
Flag = 0;
}
If (flag)
{
Printf ("yes ");
}
{
Printf ("no ");
}
If (num> 0)
{
Printf ("\ n ");
}
}
Return 0;
}
# Include <stdio. h>
# Include <string. h>
Int main ()
{
Int I;
Int flag;
Int num;
Int length;
Char string [101];
Scanf ("% d", & num );
Getchar ();
While (num --)
{
Gets (string );
Length = strlen (string );
Flag = 1;
If (string [0] = '_' | (string [0]> = 'A' & string [0] <= 'Z ') | (string [0]> = 'A' & string [0] <= 'Z '))
{
For (I = 0; I <length; I ++)
{
If (string [I] = '_' | (string [I]> = 'A' & string [I] <= 'Z ') | (string [I]> = 'A' & string [I] <= 'Z ') | (string [I]> = '0' & string [I] <= '9 '))
{
Flag = 1;
}
Else
{
Flag = 0;
}
If (flag = 0)
{
Break;
}
}
}
Else
{
Flag = 0;
}
If (flag)
{
Printf ("yes ");
}
{
Printf ("no ");
}
If (num> 0)
{
Printf ("\ n ");
}
}
Return 0;
}