Skip to content

Instantly share code, notes, and snippets.

@fanker
Created September 26, 2012 05:25
Show Gist options
  • Save fanker/3786272 to your computer and use it in GitHub Desktop.
Save fanker/3786272 to your computer and use it in GitHub Desktop.
对输入数字进行倒序输出
public class DaoXu {
public static void main (String[] args){
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.println("请输入数字:");
int num = input.nextInt();
System.out.println("输出数字为:");
while (num != 0) {
int i = num % 10; //数字num对10进行取余
num = num / 10; //数组num除以10取整
System.out.print(i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment