1 public class Leet { 2 public static void main(String[] args) { 3 Scanner scanner = new Scanner(System.in); 4 System.out.println("输入一个三位数:"); 5 int i = scanner.nextInt(); 6 int b = i / 100;//百位 7 int s = i % 100 / 10;//十位 8 int g = i % 10;//个位 9 System.out.println("百位:" + b); 10 System.out.println("十位:" + s); 11 System.out.println("个位:" + g); 12 } 13 }
运行结果: