Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. ifstream f("bani.txt");
  8. int s, a[7], b[7], aux[7] = {1, 5, 10, 50, 100, 200, 500};
  9.  
  10. for(int i = 0; i < 7; i++){
  11. f >> a[i];
  12. b[i] = a[i];
  13. }
  14.  
  15.  
  16. cout << "Suma de bani pe care doriti sa o scoateti? ";
  17. cin >> s;
  18.  
  19. int j = 6;
  20. while(s > 0){
  21. if(a[j] > 0 && s >= aux[j]){
  22. s = s - aux[j];
  23. a[j]--;
  24. } else j--;
  25. }
  26.  
  27. cout << "Au fost folosite urmatoarele bancnote: " << endl;
  28.  
  29. for(int i = 0; i < 7; i++)
  30. if(b[i] - a[i] != 0){
  31. cout << b[i] - a[i] << " bancnote de " << aux[i] << endl;
  32. }
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement