Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """Dise˜nar un programa que devuelva el cociente y el resto de una divison
- entera suponiendo que no tenemos los operadores de divisi´on (//) y de
- resto( %)
- """
- a=int(input("Dame un numero entero "))
- d=a
- b=int(input("Dame otro entero "))
- while b==0:
- b=int(input("Lo sentimos, el denominador no puede ser 0, introduzca otro numero "))
- e=b
- print("Vamos a proceder a la división de %d/%d"%(a,b))
- c=0
- if a<0:
- a=-a
- if b<0:
- b=-b
- while a>=b:
- a=a-b
- c=c+1
- if d<0 and e<0:
- a=-a
- else:
- if d<0:
- c=-c
- a=-a
- if e<0:
- c=-c
- print("El cociente es %d y el resto %d" %(c,a))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement