Cerinta completa
An array is a 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 or .
Your task is to reverse an array of integers.
Note: If you’ve already solved our C++ domain’s Arrays Introduction challenge, you may want to skip this.
Example
Return .
Function Description
Complete the function with the following parameter(s):
- : the array to reverse
Returns
- : the reversed array
Input Format
The first line contains an integer, , the number of integers in .
The second line contains space-separated integers that make up .
Constraints
Limbajul de programare folosit: cpp14
Cod:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n;
scanf("%d",&n);
int i = 0;
int array[1000];
for (i;i<n;i++)
{
scanf("%d ",&array[i]);
}
i = n-1;
for (i;i>-1;i--)
{
printf("%d ", array[i]);
}
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}
Scor obtinut: 1.0
Submission ID: 464651300
Link challenge: https://www.hackerrank.com/challenges/arrays-ds/problem
