U. Difficult Array
Problem link
https://algo.codemarshal.org/contests/diu-122-fl16-termwork/problems/U
Score: 1
CPU: 1s
Memory: 512MB
CPU: 1s
Memory: 512MB
You will be given
n
integers. You have to print them in reverse order.
Input
First you will be given an positive integer
For each test case you will be given
First you will be given an positive integer
T (1< T < 100)
, the number of test case. For each test case you will be given
N( 0 < N < 1000 )
. Then in next lines there will be n
positive integers separated by single space.
Output
For each test case you have to print
For each test case you have to print
n
numbers in reverse order.Sample
Input | Output |
---|---|
2 5 8 9 4 6 7 10 1 2 3 4 5 6 7 8 9 10 | 7 6 4 9 8 10 9 8 7 6 5 4 3 2 1 |
Solution
#include<stdio.h> int main() { int i,j,k,t,n,r[1005]; scanf("%d",&t); for(i=1;i<=t;i++){ scanf("%d",&n); for(j=0;j<n;j++){ scanf("%d",&r[j]); } printf("%d",r[n-1]); for(j=n-2;j>=0;j--){ printf(" %d",r[j]); } printf("\n"); } return 0; }
No comments:
Post a Comment