逆序存放4位数
public class ReverselyStoreIntegers{
public static void main(String args[]){
int n=1234,m;
int a,b,c,d;
d=n/1000;
c=n/100%10;
b=n/10%10;
a=n%10;
m=a*1000+b*100+c*10+d;
System.out.println("The original four digits:n="+n);
System.out.println("The four digits after each number is reversed:m="+m);
}
}
输出结果
The original four digits:n=1234
The four digits after each number is reversed:m=4321