Advertisement
shawonrog

coin change

Jul 21st, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. int main () {
  3. int i,coinlist[100],amount,coin,usecoin[100];
  4. printf("enter the amount :");
  5. scanf("%d",&amount);
  6. printf("enter the number of coin:");
  7. scanf("%d",&coin);
  8. printf("enter the coin descending order :");
  9. for(i=0;i<coin;i++)
  10. {
  11. scanf("%d",&coinlist[i]);
  12. }
  13. for(i=0;i<coin;i++)
  14. {
  15.  
  16. usecoin[i]=amount/coinlist[i];
  17. amount=amount%coinlist[i];
  18. }
  19. printf("solution : \n");
  20. for(i=0;i<coin;i++)
  21. {
  22. printf("%d %d\n",coinlist[i],usecoin[i]);
  23. }
  24.  
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement