NYOJ题目816它合法吗?

-----------------------------------------------------

AC代码:

 1 import java.io.BufferedReader;
 2 import java.io.IOException;
 3 import java.io.InputStreamReader;
 4 
 5 public class Main {
 6     
 7     public static void main(String[] args) throws IOException {
 8         
 9         BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
10         
11         boolean first=true;
12         while(first || reader.ready()){
13             first=false;
14             
15             String s=reader.readLine();
16             System.out.println(solve(s)?"Yes":"No");
17         }
18         
19     }
20     
21     public static boolean solve(String s){
22         char cs[]=s.toCharArray();
23         if(cs[0]!='_' && !Character.isLetter(cs[0])) return false;
24         for(int i=1;i<cs.length;i++){
25             if(!Character.isLetterOrDigit(cs[i]) && cs[i]!='_') return false;
26         }
27         return true;
28     }
29 
30 }

 

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=816

相关文章:

  • 2021-05-28
  • 2021-09-22
  • 2021-12-09
  • 2021-08-31
  • 2021-06-11
  • 2021-07-02
  • 2021-08-03
  • 2021-11-30
猜你喜欢
  • 2022-02-26
  • 2022-12-23
  • 2022-02-22
  • 2021-07-31
  • 2021-10-14
  • 2022-02-05
  • 2021-11-10
相关资源
相似解决方案