import java.util.*; public class Main { //http://acm.hdu.edu.cn/showproblem.php?pid=2024 public static void main(String[] args) { Scanner sc = new Scanner(System.in); int cnt = sc.nextInt(); WordCheck wc = new WordCheck(); String str = sc.nextLine(); for(int i=0; i<cnt; ++i){ str = sc.nextLine(); if(wc.isOk(str)){ System.out.println("yes"); }else{ System.out.println("no"); } } } } class WordCheck{ public WordCheck(){} boolean isNumber(char c){ if(c >= '0' && c <= '9') return true; return false; } boolean isAlpha(char c){ if(c >= 'A' && c <= 'z') return true; return false; } boolean isUnderline(char c){ if(c == '_') return true; return false; } boolean isOk(String str){ if(!(isUnderline(str.charAt(0)) || isAlpha(str.charAt(0)))){ return false; } for(int i=1; i<str.length(); ++i){ if(!(isUnderline(str.charAt(i)) || isAlpha(str.charAt(i)) || isNumber(str.charAt(i)))) return false; } return true; } }
HDU2024
最新推荐文章于 2020-09-15 22:21:57 发布