-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathArray
More file actions
55 lines (39 loc) · 1.39 KB
/
Array
File metadata and controls
55 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.
You'll be given an array of NN integers, and you have to print the integers in reverse order.
Note: If you have already solved the problem "Arrays Introduction" in the Introduction chapter of the C++ domain, you may skip this challenge.
Input Format
The first line of input contains NN, the number of integers. The next line contains NN integers separated by a space.
Constraints
1<=N<=10001<=N<=1000
1<=Ai<=100001<=Ai<=10000, where AiAi is the ithith integer in the array.
Output Format
Print the NN integers of the array in the reverse order on a single line separated by single spaces.
Sample Input
4
1 4 3 2
Sample Output
2 3 4 1
Submissions: 23521
Max Score: 10
Difficulty: Easy
More
Current Buffer (saved locally, editable)
Java 7
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int arr[] = new int[n];
for(int arr_i=0; arr_i < n; arr_i++){
arr[arr_i] = in.nextInt();
}
for(int arr_i=arr.length-1; arr_i >= 0; arr_i--){
System.out.print(arr[arr_i]+" ");
}
}
}