Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. //tablica dostepnych nominalow
  9. int N[8]={200, 100, 50, 20, 10, 5, 2, 1};
  10. int R,P, i;
  11.  
  12. cout << "Podaj reszte do wyplacenia: ";
  13. cin >> R;
  14.  
  15. i=0;
  16. while (R>0)       //dopoki nie wydano calej reszty
  17. {
  18. if (R >= N[i])  //sprawdz czy mozna wydac danym nominalem
  19. {
  20. P=R / N[i];   //ile razy wydac dany nominal
  21. R=R-(N[i]*P); //zmniejsz reszte o wydany nominal
  22. cout << N[i] << " x " << P << endl; //wypisz wynik
  23. }
  24. i++;            //rozpatrz kolejny nominal
  25. }
  26.  
  27. system("PAUSE");
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement