倒序输出一个整数(数组方法)
文章目录
import java.util.*;
public class number1 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("请输入一个整数:");
int i = sc.nextInt();
int count ;
int i1;
i1 = i;
for(count = 1;i1>10;count++)
i1 /=10;
//System.out.printf("%d\n", count);
int[] arr1;
arr1 = new int[count];
int i2;
i2 = i;
for(int j = 0;j<count;j++)
{
arr1[j] = i2%10;
i2 = i2/10;
}
for(int j = 0;j<count;j++)
System.out.printf("%d", arr1[j]);
}
}