首页 > 其他 > 详细

acm2024

时间:2015-03-18 14:03:20      阅读:250      评论:0      收藏:0      [点我收藏+]
/**
 * 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");
}
}
}

acm2024

原文:http://blog.csdn.net/a736933735/article/details/44409141

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!