相反输出
时间限制:
1000 ms | 内存限制:
65535 KB
难度:
1
-
描述
-
编写一个程序,将n个整数按相反顺序输出。
-
输入
-
有多组测试数据,以EOF结束。
每组测试数据有n个整数。
输出
- 每组数据输出一行,数字间用一个空格隔开。 样例输入
-
1 2 3 4 5 6 7 8 9 10
样例输出
-
10 9 8 7 6 5 4 3 2 1
-
有多组测试数据,以EOF结束。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int arr[] = new int[1000];
int count = 0;
while (scanner.hasNext()) {
arr[count++] = scanner.nextInt();
}
for (int i = count - 1; i >= 0; i--) {
System.out.print(arr[i] + " ");
}
System.out.println();
}
}