java 题目:取一个整数 a 从右端开始的 4~7 位。
作者:互联网
import java.util.Scanner;
public class Pro2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
System.out.println("input the number:");
int a = 0 ;
a = in.nextInt();
a = a/1000;
int[] b= new int[4];
for (int i = 0; i < b.length; i++) {
b[i] = a%10;
a = (a-b[i])/10;
}
for (int i = 0; i < b.length; i++) {
System.out.printf("第%d位数字为:%d\n",i+4,b[i]);
}
}
}
标签:java,Scanner,int,System,右端,new,题目,out 来源: https://www.cnblogs.com/rainbow7colours/p/16339528.html