Created
March 16, 2018 16:07
-
-
Save RonanUFPa/ea4e8721e2715dff49391a4f488f3c4e to your computer and use it in GitHub Desktop.
Python Vetor - Intercalar-
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding:utf-8 | |
# | |
# Programa 24 vetores - intercalados | |
# | |
# | |
import os # Biblioteca de funcoes dos sistema operativo | |
os.system("clear") #No Linux ou mac OS | |
# os.system("cls") #No windows | |
# | |
# | |
vetor = [] # Declara o vetor1 | |
vetor2 = [] # Declara o vetor2 | |
#Solicita o numero de elementos | |
n = int(input("Digite a quantidade de elementos a ser adicionados -> ")) | |
# Declara o i | |
i = 0 | |
#Recebe os elementos do vetor (Numeros inteiros) | |
while i < n: | |
temp = int(input("Digite o elemento a ser adicionado -> ")) | |
vetor.append(temp) | |
i = i + 1 | |
i = 0 | |
print("Vetor Recebido :",vetor) | |
while i < len(vetor): | |
if vetor [i] % 2 == 0: | |
vetor2.append(vetor[i]) | |
i = i + 1 | |
print("Elementos pares : ", vetor2) | |
#Fim do programa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment