Skip to content

Commit d1de901

Browse files
authored
Create Reverse me.c
1 parent 66eddd5 commit d1de901

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* You are given a list of N integers and you need to reverse it and print the reversed list in a new line.
2+
3+
Input:
4+
First-line will contain the number N.
5+
Second line will contain N space-separated integers.
6+
Output:
7+
Print the reversed list in a single line.
8+
9+
Constraints
10+
1≤N,Ai≤105
11+
Sample Input 1:
12+
4
13+
1 3 2 4
14+
Sample Output 1:
15+
4 2 3 1
16+
Sample Input 2:
17+
2
18+
9 8
19+
Sample Output 2:
20+
8 9
21+
EXPLANATION:
22+
In the first example, the reverse of the [1,3,2,4] is [4,2,3,1].
23+
In the second example, the reverse of [9,8] is [8,9]. */
24+
25+
#include <stdio.h>
26+
27+
int main(void) {
28+
29+
int n;
30+
scanf("%d",&n);
31+
int a[n];
32+
33+
for(int i=1;i<=n;i++)
34+
{
35+
scanf("%d ",&a[i]);
36+
37+
}
38+
39+
for(int i=n;i>=1;i--)
40+
{
41+
printf("%d ",a[i]);
42+
43+
}
44+
return 0;
45+
}

0 commit comments

Comments
 (0)