DigitReverser.java
public class
DigitReverser
{
public static void main(String[] args)
{
int N = Integer.parseInt(args[0]);
int M = 0;
while (N != 0) {
M = (10 * M) + (N % 10);
N = N / 10;
}
System.out.println(M);
String s = "";
while (M != 0)
{
int digit = M % 10;
s = s + digit;
M = M / 10;
}
System.out.println(s);
}
}
No comments:
Post a Comment