整数逆序

//实现整型数字的逆序输出

如:12345 逆序后:54321。


import java.util.Scanner;
public class ReverseNum{

    public static void main(String [] args){

        Scanner in = new Scanner(System.in);
        System.out.println("请输入数字:");
        int num = in.nextInt();
        int temp = 0;
        int i = 0 ;
        while((num / 10) != 0){

            i = num % 10 ;
            num /= 10;
            temp = temp * 10 + i;

        }

        temp = temp * 10 + num;
        System.out.println(temp);

    }

}

你可能感兴趣的:(整数逆序)