package algorithm.reverse;
import java.util.Scanner;
public class ReverseTheValue {
public static int reverseInt(int input)
{
int output=0;
while(input>0)
{
output=output*10+input%10;
input/=10;
}
return output;
}
public static void main(String...agrs)
{
int out;
System.out.println("Please enter a value:");
Scanner sc = new Scanner(System.in);
if(sc.hasNextInt())
System.out.println(out=reverseInt(sc.nextInt()));
}
}
No comments:
Post a Comment