Array Reversal || Hacker Rank

 Question 12 || Hacker Rank

Array Reversal || Hacker Rank

Array Reversal


Given an exhibit, of size , switch it.

Model: If cluster, , in the wake of switching it, the exhibit ought to be, .

 

Input Arrangement

The primary line contains a number, , meaning the size of the exhibit. The following line contains space-isolated numbers indicating the components of the exhibit. Limitations where is the component of the exhibit.

Yield Arrangement

The result is taken care of by the code given in the proofreader, which would print the exhibit.

 

Test Info 0

6

16 13 7 2 1 12

 

Test Result 0

12 1 2 7 13 16

 

Clarification 0

Given cluster, = . In the wake of turning around the exhibit, =

 

Test Information 1

7

1 13 15 20 12 13 2

 

Test Result 1

2 13 12 20 15 13 1

 

Test Information 2

8

15 5 16 15 17 11 5 11

 

Test Result 2

11 5 11 17 15 16 5 15



#include <stdio.h>
#include <stdlib.h>

#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int arr[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    for (int i = n - 1; i >= 0; i--) {
        printf("%d ", arr[i]);
    }
    return 0;
}


Output:

Array Reversal



Post a Comment

0 Comments