fork download
  1. #include <stdio.h>
  2.  
  3. #define N 5
  4.  
  5. int main(void) {
  6. int nominaly[N] = { 20, 10, 5, 2, 1 };
  7. int kwota = 0;
  8.  
  9. printf("Podaj sume pieniedzy: ");
  10. scanf("%d", &kwota);
  11.  
  12. int i;
  13. for (i = 0; i < N; i++) {
  14. int n = nominaly[i];
  15. int r = kwota/n;
  16. if (r > 0) {
  17. printf("%d x %d\n", r, n);
  18. }
  19. kwota -= r*n;
  20. }
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 1792KB
stdin
58
stdout
Podaj sume pieniedzy: 2 x 20
1 x 10
1 x 5
1 x 2
1 x 1