标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 57097 Accepted Submission(s):
22525
import java.util.*; class Main{ public static void main(String args[]) {Scanner cin=new Scanner(System.in); int n=cin.nextInt(); String s=cin.nextLine(); while(n-->0) { String str=cin.nextLine(); char a[]=str.toCharArray(); int flag=0; for(int i=0;i<str.length();i++) { if((a[0]>=‘a‘&&a[0]<=‘z‘)||(a[0]>=‘A‘&&a[0]<=‘Z‘)||a[0]==‘_‘) { flag=1; } else { System.out.println("no"); break; } if(i>0&&flag==1) { if((a[i]>=‘a‘&&a[i]<=‘z‘)||(a[i]>=‘A‘&&a[i]<=‘Z‘)||a[i]==‘_‘||(a[i]>=‘0‘&&a[i]<=‘9‘)) { flag=1; } else { flag=0; System.out.println("no"); break; } } } if(flag==1) System.out.println("yes"); } } } 这个地方要吃掉回车键,可以用nextLine();吃掉回车键;
标签:
原文地址:http://www.cnblogs.com/1314wamm/p/5361325.html