如;12345 反转后输出变为:54321
// 导包
import java.util.Scanner;
public calss ReverseNum{
public static void main(String[] agrs){
//创建对象
Scanner in = new Scanner(System.in);
// 引用
int num = in.nextInt();
int temp = 0;
//用while 循环进行遍历
int i = 0;
while ((num/10) != 0){
i = num%10;
num /= 0;
temp = temp * 10+i;
}
temp = temp *10+num;
System.out.ptintln(temp);
}
}
|
|