Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # RetoHxC.py
- #
- # Copyright 2013 quuim <quuim.py@gmail.com>
- # qlabs.tk/blog
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- import os, sys # Estas librerias las usare solamente por cuestiones de estetica (os.system("clear")) asi que no creo que me descalifiquen por eso...
- def main():
- cadena = [1,1,1,1] #Se crea cadena con 4 enteros
- try:
- cadena[0] = int(raw_input("Ingrese el dato 1:")) #Se cambian los cuatro enteros por los numeros que el usuario introduzca
- cadena[1] = int(raw_input("Ingrese el dato 2:"))
- cadena[2] = int(raw_input("Ingrese el dato 3:"))
- cadena[3] = int(raw_input("Ingrese el dato 4:"))
- FuncionQueHaceElTrabajo(cadena) # Se envían los datos a la funcion que los procesará
- except:
- print "Ingrese un dato valido..." # Si ingresa un caracter no permitido por los integers o no ingresa nada le hará volver a introducir los valores
- raw_input()
- os.system("clear") # Si usas windows cambia "clear" por "cls", si usas otros sistemas operativos cambialo por el comando de limpiar pantalla
- main()
- return 0
- def FuncionQueHaceElTrabajo(cadena):
- for i in cadena:
- if i==cadena[0] and i==cadena[1] and i==cadena[2] and i==cadena[3]: # Si todos los numeros son iguales avis y termina el programa
- print "\n\nTodos los numeros son iguales"
- raw_input()
- break
- if (i==cadena[0] and i==cadena[1] and i==cadena[2]) or (i==cadena[1] and i==cadena[2] and i==cadena[3]) or (i==cadena[2] and i==cadena[3] and i==cadena[0]) or (i==cadena[3] and i==cadena[0] and i==cadena[1]): # Si el numero es igual a otros 2 el programa volverá al for i in cadena
- continue
- else: # Si i no es igual ni a todos ni a 2 otros empieza a calcular si es más grande o pequeño que el resto
- print "\n\nEl número", i, "es distinto, rianse de él"
- if (i<cadena[0] and i<cadena[1] and i<cadena[2]) or (i<cadena[1] and i<cadena[2] and i<cadena[3]) or (i<cadena[2] and i<cadena[3] and i<cadena[0]) or (i<cadena[3] and i<cadena[0] and i<cadena[1]):
- print "También es el más pequeño"
- if (i>cadena[0] and i>cadena[1] and i>cadena[2]) or (i>cadena[1] and i>cadena[2] and i>cadena[3]) or (i>cadena[2] and i>cadena[3] and i>cadena[0]) or (i>cadena[3] and i>cadena[0] and i>cadena[1]):
- print "También es el más grande"
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement