Java反向输出数字

package hello;

import java.util.Scanner;

public class Zhengshufenjie {
    
    

	public static void main(String[] args) {
    
    
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int number = in.nextInt();
		int result = 0;
		 do{
    
    
			int digit = number % 10;
			result = result * 10 + digit;
			number = number / 10;
		}while (number > 0);
		System.out.println(result);
	}

}

输出结果为

532
235

猜你喜欢

转载自blog.csdn.net/Mr_zhang0223/article/details/113133613