标签:
#include "cstdio"
#include "cstring"
int compare(char s[]);
int main(){
int i,n,j;
char s[110];
while(~scanf("%d",&n)){
getchar();
for(i=0;i<n;i++){
gets(s);
if(compare(s)) printf("yes\n");
else printf("no\n");
}
}
return 0;
}
int compare(char s[]){
int n,i;
n=strlen(s);
for(i=0;i<n;i++){
if(i==0){
if(s[i]==‘_‘) continue;
if(s[i]<=‘9‘ && ‘0‘<=s[i]) break;
if(s[i]==‘ ‘) break;
if(s[i]<‘A‘ || (‘Z‘<s[i] && s[i]<‘a‘) || ‘z‘<s[i] ) break;
}
else{
if(s[i]==‘_‘) continue;
if(s[i]<=‘9‘ && ‘0‘<=s[i]) continue;
if(s[i]<‘A‘ || (‘Z‘<s[i] && s[i]<‘a‘) || ‘z‘<s[i] ) break;
}
}
if(i!=n)
return 0;
else
return 1;
}
标签:
原文地址:http://www.cnblogs.com/sureli/p/5090316.html