1 package shangji.tl.test; 2 3 import java.util.Scanner; 4 5 public class QiuShuWei { 6 7 public static void main(String[] args) { 8 9 System.out.print("输入一个4位数的正整数:"); 10 Scanner input = new Scanner(System.in); 11 int number = input.nextInt(); 12 13 int ones = number % 10, tens = number / 10 % 10, 14 hundreds = number / 100 % 10, thousands = number / 1000 % 10; 15 16 System.out.println(ones); 17 System.out.println(tens); 18 System.out.println(hundreds); 19 System.out.println(thousands); 20 21 } 22 23 24 25 }