Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Monday 31 October 2016

U. Difficult Array

Problem link
https://algo.codemarshal.org/contests/diu-122-fl16-termwork/problems/U


Score: 1

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 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 n numbers in reverse order.

Sample

InputOutput
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