算法训练 判定数字

Posted watchfree

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了算法训练 判定数字相关的知识,希望对你有一定的参考价值。

算法训练 判定数字  
时间限制:1.0s   内存限制:512.0MB
    
  编写函数,判断某个给定字符是否为数字。
样例输入
9
样例输出
yes
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new  Scanner(System.in);
        String s=sc.nextLine();
        char ch=s.charAt(0);
        if(Character.isDigit(ch)){
            System.out.println("yes");
        }
        else
            System.out.println("no");

    }

}

 

以上是关于算法训练 判定数字的主要内容,如果未能解决你的问题,请参考以下文章