Advertisement
michael_xgrind

Vetor

Jan 19th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import random
  2. i = 0
  3. pvet = []
  4. #for i in range(10):
  5. while i < 10:
  6.     x = random.randint(1, 15)
  7.     pvet.append(x)
  8.     i += 1 #incrementa
  9. print('Primeiro Vetor: ', pvet)
  10.  
  11. svet = []
  12. i = 0
  13. #for i in range(10):
  14. while i < 10:
  15.     x = random.randint(1, 15)
  16.     svet.append(x)
  17.     i += 1 #incrementa
  18. print('Segundo Vetor: ', svet)
  19.  
  20. tvet = []
  21. i = 0
  22. a = 0
  23. b = 0
  24. #for i in range(20):
  25. while i < 20:
  26.     if a < 10:
  27.         tvet.append(pvet[i])
  28.         a += 1
  29.     if b < 10:
  30.         tvet.append(svet[i])
  31.         b += 1    
  32.     i += 1 #incrementa
  33. print('Intercalacao de Vetores: ', tvet)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement