pesquisa

URI PROBLEMA 1175 - Troca em Vetor I SOLUÇÃO EM PYTHON

URI Online Judge | 1175

Troca em Vetor I

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Faça um programa que leia um vetor N[20]. Troque a seguir, o primeiro elemento com o último, o segundo elemento com o penúltimo, etc., até trocar o 10º com o 11º. Mostre o vetor modificado.

Entrada

A entrada contém 20 valores inteiros, positivos ou negativos.

Saída

Para cada posição do vetor N, escreva "N[i] = Y", onde i é a posição do vetor e Y é o valor armazenado naquela posição.



URI Online Judge | 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.





N=[]
for i in range(20):
    x=int(input())
    N.append(x)
a=N[::-1]
for j in range(20):
    print('N[{}] = {}'.format(j,a[j]))

Postar um comentário

0 Comentários