Legal identifier of C Language
Legal identifier of C LanguageTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 39100 Accepted Submission (s): 15614
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 problem-solving ideas: isalpha function link: http://blog.163.com/caipeipei_love%40126/blog/static/25966032201032784630227/ isalnum function link: http://see.xidian.edu.cn/cpp/html/112.htmlsource code :#include
# Include
# Include
# Include
Int main () {int I, n, f; char str [51]; scanf ("% d", & n); getchar (); while (n --) {gets (str); f = 1; if (str [0]! = '_'&&! Isalpha (str [0]) f = 0; I = 1; while (str [I]! = '\ 0' & f = 1) {if (str [I]! = '_'&&! Isalnum (str [I]) f = 0; I ++;} if (f = 0) printf ("no \ n "); else printf ("yes \ n");} system ("pause"); return 0 ;}