Displaying an integer reverse(整数倒置,不受位数限制)

Bertha 。 2022-08-09 06:20 105阅读 0赞
  1. 问题及代码:
  2. package first;
  3. import java.util.Scanner;
  4. public class text {
  5. public static void main(String[] args) {
  6. System.out.println("请输入一个整数:");
  7. Scanner get = new Scanner(System.in);
  8. int a = get.nextInt();
  9. int sum = 0;
  10. while (a != 0) {
  11. int b = a % 10;
  12. sum = sum * 10 + b;
  13. a = a / 10;
  14. }
  15. System.out.println(+sum);
  16. }
  17. }
  18. 运行结果:

Center

发表评论

表情:
评论列表 (有 0 条评论,105人围观)

还没有评论,来说两句吧...

相关阅读