Algorithm
Problem Name: beecrowd | 1175
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1175
Array change I
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
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 Sample | Output Sample |
0 |
N[0] = 230 |
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
int main() {
int vetor[20];
int i;
for (i = 0; i < 20; i++) {
scanf("%d", &vetor[i]);
}
for (i = 0; i < 20; i++) {
printf("N[%d] = %d\n", i, vetor[19 - i]);
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with Javascript Programming
Code -
Javascript Programming
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.split('\n');
let d = [];
for(var c = 0; c < 20; c++){
let f = lines.shift();
d.push(f);
}
d.reverse();
for(var g = 0; g < 20; g++){
console.log(`N[${g}] = ${d[g]}`);
}
Copy The Code &
Try With Live Editor
Input
Output
#3 Code Example with Python Programming
Code -
Python Programming
d = []
for c in range(0, 20):
f = input()
d += [f]
d.reverse()
for g in range(0, 20):
print(f'N[{g}] = {d[g]}')
Copy The Code &
Try With Live Editor
Input
Output