33 lines
		
	
	
		
			775 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			775 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| def rendreMonnaie(prix, monnaie):
 | |
|     x1, x2, x3, x4, x5 = monnaie  # Chaques billets en entree (20, 10, 5, 2, 1)
 | |
| 
 | |
|     given = (x1*20) + (x2*10) + (x3*5) + (x4*2) + (x5*1)
 | |
| 
 | |
|     rest = given - prix
 | |
|     if rest < 0:
 | |
|         return f"vous n'avez pas assez d'argent. Il manque : {-rest}"
 | |
| 
 | |
|     o1 = rest // 20
 | |
|     rest = rest % 20
 | |
| 
 | |
|     o2 = rest // 10
 | |
|     rest = rest % 10
 | |
| 
 | |
|     o3 = rest // 5
 | |
|     rest = rest % 5
 | |
| 
 | |
|     o4 = rest // 2
 | |
|     rest = rest % 2
 | |
| 
 | |
|     o5 = rest // 1
 | |
|     rest = rest % 1
 | |
| 
 | |
|     return o1, o2, o3, o4, o5
 | |
| 
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     prix = int(input("quel est le prix :"))
 | |
|     print("entrez maintenant les billets")
 | |
|     mon = (int(input("20e:")),int(input("10e:")),int(input("5e:")),int(input("2e:")),int(input("1e:")))
 | |
|     print(rendreMonnaie(prix, mon))
 |