acm2024

/**
 * C语言合法标识符
 */
import java.util.*;
public class acm2024 {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
in.nextLine();
while (n--!= 0) {
String str = in.nextLine();
char[] chs = str.toCharArray();
//Character.isLetter(chs[0])确定指定字符是否为字母
if (!(Character.isLetter(chs[0]) || chs[0] == '_')) {
System.out.println("no");
continue;
}
boolean flag = true;
for (int i = 1; i < chs.length; i++) {
//Character.isDigit(chs[i])确定指定字符是否为数字 Character.isLetter(chs[i])确定指定字符是否为字母
if (!(Character.isDigit(chs[i]) || Character.isLetter(chs[i]) || chs[i] == '_')) {
flag = false;
break;
}
}
if(flag)
System.out.println("yes");
else
System.out.println("no");
}
}
}
posted @ 2017-04-24 11:07  yfceshi  阅读(103)  评论(0编辑  收藏  举报