Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Caricato un vettore di numeri pari ricercarne il valore massimo ##
- ' ricerca del massimo '
- def cerca_max(vett, dim):
- for i in range(dim):
- if i == 0:
- max = vett[i]
- else:
- if max < vett[i]:
- max = vett[i]
- return max
- def main():
- vett, dim = [], 4
- ' caricamento del vettore '
- for i in range(dim):
- num = int(input("Numero pari: "))
- while num % 2 != 0:
- num = int(input("Devi inserire un numero pari! "))
- vett.append(num)
- ' stampa dei risultati '
- print("Numeri pari: ", vett)
- print("\nValore massimo: ", cerca_max(vett, dim))
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment