public static void main(String[] args) throws IOException {
System.out.println("请在下一行输入一个不多于五位的正整数的值,按回车键");
getNum();
}
/**
* @throws IOException
*/
private static void getNum() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
int num = Integer.parseInt(str);
System.out.println(num + "的位数为:" + str.length());
System.out.println("位数逆序分别为:");
for (int i = str.length() - 1; i >= 0; i--) {
System.out.print(str.charAt(i) + " ");
}
System.out.println();
} |