首页 > 编程语言 > 详细

java 反向打印一个数字

时间:2019-12-27 15:21:26      阅读:78      评论:0      收藏:0      [点我收藏+]

 

//print all digits of the given number

import java.util.Scanner;

public class Numbers {

    public static void main(String[] args) {
        int num;
        Scanner ip = new Scanner(System.in);
        System.out.print("Enter a number: ");
        num = ip.nextInt();
        while (num > 0) {
            int rem = num % 10;
            System.out.println(rem);
            num = num / 10;
        }
        ip.close();
    }
}

OUTPUT:
Enter a number: 32451234
4
3
2
1
5
4
2
3

 

java 反向打印一个数字

原文:https://www.cnblogs.com/sea-stream/p/12107062.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!