example2_7.java
来自「主要是对于JAVA的编程的基本语言 希望能够帮得上你。」· Java 代码 · 共 34 行
JAVA
34 行
package exercise;
import java.io.*;
public class Example2_7 {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Please input a positive integer: ");
BufferedReader br=new BufferedReader(
new InputStreamReader(System.in));
try {
int n=Integer.parseInt(br.readLine());
System.out.println("The number you input is "+n);
//用while循环输出1到n
int count=1;
while(count<=n){
System.out.print(count+", ");
count++;
if(count%8==1){
System.out.println();
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?