java获取整数各个位上的数
作者:互联网
原链接:https://blog.csdn.net/qq_27139155/article/details/79702758
我以前遇到过,但是写的不够简单,比较复杂
代码如下:
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc =new Scanner(System.in); int num=sc.nextInt(); int f[]=new int[10]; //四位数 f[0]=(num)%10; f[1]=(num/10)%10; f[2]=(num/100)%10; f[3]=(num/1000)%10; System.out.print(f[3]+" "+f[2]+" "+f[1]+" "+f[0]); } }
标签:10,java,Scanner,int,System,整数,位上,num 来源: https://www.cnblogs.com/jessezs/p/12450635.html