HDOJ 2024 legal identifier of C language (water question, talk about identifier)
C Legal identifier Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission (s): 42681 Accepted Submission (s): 17117
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
Question: The question is very simple and there is no difficulty or skill. It focuses on the legal identifier of the C language. Definition: in advanced computer languages, effective character sequences used for naming variables, symbolic constant names, functions, arrays, and types are collectively referred to as identifiers. Note: 1. the C language specifies that an identifier can only contain letters, numbers, and underscores (_), and must contain letters or underscores. 2. the compiling system considers uppercase letters and lowercase letters as two different characters.
The AC code is as follows:
# Include
# Include
Int main () {int len, n, I; char str [55]; scanf ("% d", & n); getchar (); // The while (n --) {gets (str); if (str [0] <65 | str [0]> 122) characters must be absorbed here) & str [0]! = '_') Printf ("no \ n"); else {int k = 0; len = strlen (str); for (I = 1; I
57) | str [I]> 122) & str [I]! = '_') {K = 1; break;} if (! K) printf ("yes \ n"); else printf ("no \ n") ;}} return 0 ;}