Output in reverse numerical order of positive integers (Java)

This question requires the input of a positive integer, which is output in the reverse order of the numbers.

Input format:
Input a positive integer.

Output format:
output a number in the reverse order of the number of the input positive integer.

Input example:
5236

Sample output:
6325

import java.util.Scanner;

public class Main{
    
    
	public static void main(String[] args) {
    
    
		Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int a ; 
        while(num!=0) {
    
    
        	a=num%10 ;
        	num/=10;
        	System.out.print(a);
        }
	}
}

Guess you like

Origin blog.csdn.net/weixin_51430516/article/details/115103342