HDU 2024 C语言合法标识符

 1 #include <ctype.h>
 2 #include <stdio.h>
 3 int main()
 4 {
 5     int n, d, i;
 6     char sym[64];
 7     scanf("%d%*c", &n);
 8     while (n--)
 9     {
10         gets(sym);
11         if (sym[0] != '_' && !isalpha(sym[0]))
12         {
13             puts("no");
14             continue;
15         }
16         for (d = i = 1 ; sym[i] ; i++)
17         {
18             if (!isalnum(sym[i]) && sym[i] != '_')
19             {
20                 d = 0;
21                 break;
22             }
23         }
24         puts(d ? "yes" : "no");
25     }
26     return 0;
27 }

posted on 2012-08-02 16:14  mycapple  阅读(318)  评论(1)    收藏  举报

导航