将一个整数反转输出例如:2643 输出则为:3462

package com;


import java.util.Scanner;


public class Fanzhuan {
public static void main(String[] args){
int n;
int yu;
int ans = 0;
Scanner sca = new Scanner(System.in);
n = sca.nextInt();
while(true){
yu = n % 10;
n = (int)n/10;
ans =  ans * 10 + yu; 
if(n == 0)
{
break;
}

}
sca.close();
System.out.println(ans);

}


}

你可能感兴趣的:(将一个整数反转输出例如:2643 输出则为:3462)