用java求一個數的百位數,十位數,個位數,


package com.Hello;
import java.util.Scanner;
public class hello {

public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int N,a,b,c;
System.out.println("請輸入數:");
N=sc.nextInt();
a=(int)(N/100)%10;
b=(int)(N/10)%10;
c=(int)(N/1)%10;
System.out.println("\t輸出的結果為:");
System.out.println("個位數:"+c);
System.out.println("十位數:"+b);
System.out.println("百位數:"+a);
                }

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM