-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverse array.cpp
More file actions
46 lines (33 loc) · 804 Bytes
/
Reverse array.cpp
File metadata and controls
46 lines (33 loc) · 804 Bytes
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
/*
Print array in reverse order.
Note: Try solving this using recursion. Do not use any inbuilt functions/libraries for your main logic.
Input Format
First line of input contains N - the size of the array and second line contains the elements of the array.
Constraints
1 <= N <= 100
0 <= ar[i] <= 1018
Output Format
Print the given array in reverse order.
Sample Input 0
5
2 19 8 15 4
Sample Output 0
4 15 8 19 2
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n;
cin>>n;
long long A[n];
for(int i=0;i<n;i++)
cin>>A[i];
for(int i=(n-1);i>=0;i--)
cout<<A[i]<<" ";
return 0;
}