杭电Hd 2024 C语言合法标识符

来源:互联网 发布:高分三号卫星数据下载 编辑:程序博客网 时间:2024/04/27 14:09

//简单题,贵在严谨

import java.util.Scanner;
public class Hd2024 {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);

  int n = Integer.valueOf(sc.nextLine());
  String b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";
  String c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
  
  for (int i = 0; i < n; i++) {
   int d=0;
   String a = sc.nextLine();
   if (b.indexOf(a.charAt(0)) == -1) {
    System.out.println("no");
   }
   else{
   for (int j = 0; j < a.length(); j++) {
            if(c.indexOf(a.charAt(j))!=-1)
             d++;
   }
   if(d==a.length()){
    System.out.println("yes");
   }
   else{ System.out.println("no");
   }
   
   }
  }
  
 }
}

 

原创粉丝点击