首页 > 代码库 > 杭电2024

杭电2024

 1 #include<stdio.h>
 2 char s[51];
 3 int lenth(char s[])
 4 {
 5     int i=0;
 6     while(s[i])
 7         ++i;
 8     return i;
 9 }
10 int main()
11 {
12     int i,n;
13     while(~scanf("%d",&n))
14     {
15         getchar();
16         while(n--)
17         {
18             gets(s);
19             int len=lenth(s);
20             for(i=0; i<len; ++i)
21             {
22                 if(i)
23                 {
24                     if(!(s[i]==_||(s[i]>=a&&s[i]<=z)||(s[i]>=A&&s[i]<=Z)||(s[i]>=0&&s[i]<=9)))
25                         break;
26                 }
27                 else
28                     if(!( s[i]==_ || (s[i]>=a&&s[i]<=z) || (s[i]>=A&&s[i]<=Z) ))
29                         break;
30             }
31             if(i==len)
32                 printf("yes\n");
33             else
34                 printf("no\n");
35         }
36     }
37     return 0;
38 }

 

杭电2024