杭电 2024

 1 #include <iostream>
 2 #include <string>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int n;
 8     string str;
 9     int flag;
10     while (cin>>n)
11     {
12         cin.get();// 上一行的处理回车
13         for (int i=0; i<n; i++)
14         {
15             
16             getline(cin,str);
17 //            cin>> str;
18 
19             flag = 1;
20             for (int i=0; i<str.length();i++)
21             {
22                 if (!(isdigit(str[i])||isalpha(str[i])|| str[i]=='_'))
23                 {
24                     flag = 0;
25                 }
26             }
27             if (isdigit(str[0]))
28             {
29                 flag = 0;
30             }
31             if (!flag)
32             {
33                 cout<<"no"<<endl;
34             }
35             else
36             {
37                 cout<<"yes"<<endl;
38             }
39         }
40     }
41     return 0;
42 }
原文地址:https://www.cnblogs.com/lingc/p/3726289.html