Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. void info(int a,int b,int c,int money)
  5. {
  6. printf("%d PLN = %d*100 + %d*50 + %d*20\n",money,a,b,c);
  7.  
  8. }
  9.  
  10. void foo(int money,int step)
  11. {
  12. int a,b,c = 0;
  13. int local_money = money;
  14. if (step == 1)
  15. {
  16. a = floor(money/100);
  17. money = money -a*100;
  18. b = floor(money/50);
  19. money =money -b*50;
  20. c = floor(money/20);
  21. info(a,b,c,local_money);
  22.  
  23. }
  24. else if(step ==2)
  25. {
  26. b = floor(money/50);
  27. money =money -b*50;
  28. a = floor(money/100);
  29. money = money -a*100;
  30. c = floor(money/20);
  31. info(a,b,c,local_money);
  32. }
  33.  
  34. else if(step==3)
  35. {
  36. c = floor(money/20);
  37. money =money -c*20;
  38. b = floor(money/50);
  39. money =money -b*50;
  40. info(a,b,c,local_money);
  41.  
  42. }
  43.  
  44. }
  45.  
  46.  
  47.  
  48. int main()
  49. {
  50.  
  51. int money = 0;
  52. scanf("%d",&money);
  53. printf("Your money : %d\n", money);
  54. for(int i=1; i<4; ++i)
  55. {
  56. foo(money,i);
  57. }
  58.  
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement