Input method: Enter an integer type first, and then loop through the string with spaces.
Think: integer type with scanf_s () input. Cycle The character of the buffer with the getchar () function before entering the string. Then, enter a string with a space with the "gets_s ()" function. (Note that each string is entered as a whole ).
#include <stdio.h>#include<cstring>intMain () {intN; CharD; Charc[Wuyi]; while(scanf_s ("%d%c", &n,&d)! =EOF) {GetChar (); while(n--) {gets_s (c); inti =1; if(c[0] =='_'|| (c[0] >='a'&&c[0] <='Z') || (c[0] >='A'&&c[0] <='Z')) { for(i =1; I < strlen (c); i++) { if(C[i] = ='_') Continue; Else if(C[i] >='a'&&c[i] <='Z') Continue; Else if(C[i] >='A'&&c[i] <='Z') Continue; Else if(C[i] >='0'&&c[i] <='9') Continue; Else Break; } } if(I >=strlen (c)) printf ("yes\n"); Elseprintf ("no\n"); } }}
C-Language legal identifiers (hud2024)