mycapple

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 }

分类:

技术点:

相关文章:

  • 2021-12-08
  • 2022-02-10
  • 2022-02-05
  • 2022-02-07
  • 2022-01-29
  • 2021-12-21
  • 2022-01-19
猜你喜欢
  • 2022-03-07
  • 2021-12-23
  • 2022-01-07
  • 2021-07-02
相关资源
相似解决方案