1175 Array change I

SemiColon
By -
0
URI Online Judge | 1175

Array change I

Write a program that reads an array N [20]. After, change the first element by the last, the second element by the last but one, etc.., Up to change the 10th to the 11th. print the modified array.

Input

The input contains 20 integer numbers, positive or negative.

Output

For each position of the array N print "N[i] = Y", where i is the array position and Y is the number stored in that position.
Input SampleOutput Sample
0
-5
...
63
230
N[0] = 230
N[1] = 63
...
N[18] = -5
N[19] = 0

Solution:


#include <stdio.h>
int main()
{
   int ar[20], temp,i,j;

    for(i=0; i<=19; i++)
        scanf("%d",&ar[i]);
    for(i=0, j=19; i<j; i++, j--)
    {
        temp=ar[i];
        ar[i]=ar[j];
        ar[j]=temp;
    }
    for(i=0; i<=19; i++)
        printf("N[%d] = %d\n",i,ar[i]);

    return 0;
}


Tags:

Post a Comment

0Comments

Post a Comment (0)