C语言合法标识符
#include<iostream>
using namespace std;
#include<string>
int main()
{
int i,j,n,k=0;
string a;
while(cin>>n)
{
getline(cin,a);
for(i = 0 ; i < n ; i++)
{
getline(cin,a);
if(a[0] >= '0' && a[0]<= '9')
{
cout<<"no"<<endl;
continue;
}
for(j = 0 ; j < a.size() ; j++)
{
if( (a[j] >= 'a' && a[j] <= 'z' ) || (a[j] >= 'A' && a[j] <= 'Z' ) || ( a[j] >= '0' && a[j]<= '9' ) || a[j] == '_')
k++;
}
if(k == a.size())
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
k = 0;
}
}
return 0;
}