【发布时间】:2018-02-12 02:46:41
【问题描述】:
import java.util.Scanner;
public class TestingCode {
public static void main(String[] args)
{
int n;
int integers;
Scanner scan = new Scanner(System.in);
System.out.println("Enter a single positive integer, n: ");
n = scan.nextInt();
System.out.println("Enter n integers separated by spaces: ");
integers = scan.nextInt();
for (int i=0; i < n; i++) {
int input = scan.nextInt();
System.out.println(input);
}
scan.close();
}
}
输入
输入一个正整数,n:
5
输入 n 个用空格分隔的整数:
1 2 3 4 5
输出
2
3
4
5
预期输出
它应该打印出来
1
2
3
4
5
【问题讨论】:
-
删除
integers = scan.nextInt(); -
比你 Elliott,解决了问题!
标签: java for-loop input printing integer