Ordine numeri


testo

Scrivere un programma che legge in input 3 numeri interi e li stampa in ordine decrescente( i numeri devono essere diversi tra loro).

SOLUZIONI

  • n1 = int(input(“inserisci il primo numero: “))
  • n2 = int(input(“inserisci il secondo numero: “))
  • n3 = int(input(“inserisci il terzo numero: “))
  • if ((n1 != n2) & (n2 != n3) & (n1 != n3)):
  •     if ((n1 > n2) & (n1 > n3)):
  •         print(n1)
  •         if (n2 > n3):
  •             print(n2)
  •             print(n3)
  •         else:
  •             print(n3)
  •             print(n2)
  •     else:
  •         if((n2 > n1) & (n2 > n3)):
  •             print(n2)
  •             if (n1 > n3):
  •                 print(n1)
  •                 print(n3)
  •             else:
  •                 print(n3)
  •                 print(n1)
  •         else:
  •             print(n3)
  •             if (n1 > n2):
  •                 print(n1)
  •                 print(n2)
  •             else:
  •                 print(n2)
  •                 print(n1)
  • else:
  •     print(“Non ci provare!”)
Did you find this article useful? Share It on...
Buffer this pageShare on FacebookShare on Google+Tweet about this on TwitterShare on TumblrShare on LinkedInEmail this to someonePrint this page

Un sito dedicato all' Open Source

Si prega di attivare i Javascript! / Please turn on Javascript!

Javaskripta ko calu karem! / Bitte schalten Sie Javascript!

S'il vous plaît activer Javascript! / Por favor, active Javascript!

Qing dakai JavaScript! / Qing dakai JavaScript!

Пожалуйста включите JavaScript! / Silakan aktifkan Javascript!