Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- void info(int a,int b,int c,int money)
- {
- printf("%d PLN = %d*100 + %d*50 + %d*20\n",money,a,b,c);
- }
- void foo(int money,int step)
- {
- int a,b,c = 0;
- int local_money = money;
- if (step == 1)
- {
- a = floor(money/100);
- money = money -a*100;
- b = floor(money/50);
- money =money -b*50;
- c = floor(money/20);
- info(a,b,c,local_money);
- }
- else if(step ==2)
- {
- b = floor(money/50);
- money =money -b*50;
- a = floor(money/100);
- money = money -a*100;
- c = floor(money/20);
- info(a,b,c,local_money);
- }
- else if(step==3)
- {
- c = floor(money/20);
- money =money -c*20;
- b = floor(money/50);
- money =money -b*50;
- info(a,b,c,local_money);
- }
- }
- int main()
- {
- int money = 0;
- scanf("%d",&money);
- printf("Your money : %d\n", money);
- for(int i=1; i<4; ++i)
- {
- foo(money,i);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement