-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArrays - DS.java
More file actions
63 lines (47 loc) · 1.26 KB
/
Arrays - DS.java
File metadata and controls
63 lines (47 loc) · 1.26 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
56
57
58
59
60
61
62
/* An array is a type of data structure that stores elements of the same type in a contiguous block of memory. In an array, , of size , each memory location has some unique index, (where ), that can be referenced as (you may also see it written as ).
Given an array, , of integers, print each element in reverse order as a single line of space-separated integers.
Note: If you've already solved our C++ domain's Arrays Introduction challenge, you may want to skip this.
Input Format
The first line contains an integer, (the number of integers in ).
The second line contains space-separated integers describing .
Constraints
Output Format
Print all integers in in reverse order as a single line of space-separated integers.
Sample Input 1
CopyDownload
Array: arr
1
4
3
2
4
1 4 3 2
Sample Output 1
2 3 4 1
Arrays - DSArrays - DS
*/
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
public static void main (String args[])
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
for(int i=n-1;i>=0;i--)
{
System.out.print(+a[i]);
System.out.print(" ");
}
}
}