看了看能力
可以逆序输出
import java.util.Scanner;
public class Hello {
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
int number=in.nextInt();
do{
int digit=number%10;
System.out.print(digit);
number/=10;
}while(number>0);
System.out.println();
}
}
但可能会出现不符合实际情况如下图,007
改进
2*10+5=25
25*10+3=253
import java.util.Scanner;
public class Hello {
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
int number=in.nextInt();
int result=0;
do{
int digit=number%10;
result=result*10+digit;
System.out.print(digit);
number/=10;
}while(number>0);
System.out.println();
System.out.println(result);
}
}
do while;和while还是有点区别的
当do{}while;换成while{} number=0结果不同如图