public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int a = n % 10;
int b = n % 100;
int c = n % 1000;
int d = n % 10000;
System.out.println("后1位:" + a);
System.out.println("后2位:" + b);
System.out.println("后3位:" + c);
System.out.println("后4位:" + d);
System.out.println("个位:" + a);
System.out.println("十位:" + n / 10 % 10);
System.out.println("百位:" + n / 100 % 10);
System.out.println("千位:" + n / 1000 % 10);
}
取一个数的后几位+取各个位上的数
最新推荐文章于 2022-03-30 16:58:45 发布