Created
September 26, 2012 05:25
-
-
Save fanker/3786272 to your computer and use it in GitHub Desktop.
对输入数字进行倒序输出
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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