Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int[] numbers = new int[n];
- for (int i = 0; i < n; i++) {
- numbers[i] = Integer.parseInt(scanner.nextLine());
- }
- for (int i = n - 1; i >= 0; i--) {
- System.out.print(numbers[i] + " ");
- }
- }
- }
- OR:
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- String[] numbers = new String[n];
- for (int i = n - 1; i >= 0; i--) {
- numbers[i] = scanner.nextLine();
- }
- System.out.println(String.join(" ", numbers));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement