Advertisement
MinhNGUYEN2k4

Untitled

Oct 11th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int long long
  3.  
  4. using namespace std;
  5.  
  6. int money;
  7. int d[10];
  8.  
  9. signed main()
  10. {
  11.   ios_base::sync_with_stdio(false);
  12.   cin.tie(0);
  13.   cout << "Nhap so tien vao: ";
  14.   cin >> money;
  15.   int cur[10] = {500, 200, 100, 50, 20, 10, 5, 2, 1};
  16.   int i=0;
  17.   while (money > 0)
  18.   {
  19.     if (money >= cur[i])
  20.     {
  21.       money -= cur[i];
  22.       d[i]++;
  23.     }
  24.     else i++;
  25.   }
  26.   cout << '\n';
  27.   if (d[0] != 0) cout << "So to 500k la: " << d[0] << '\n';
  28.   if (d[1] != 0) cout << "So to 200k la: " << d[1] << '\n';
  29.   if (d[2] != 0) cout << "So to 100k la: " << d[2] << '\n';
  30.   if (d[3] != 0) cout << "So to 50k la: " << d[3] << '\n';
  31.   if (d[4] != 0) cout << "So to 20k la: " << d[4] << '\n';
  32.   if (d[5] != 0) cout << "So to 10k la: " << d[5] << '\n';
  33.   if (d[6] != 0) cout << "So to 5k la: " << d[6] << '\n';
  34.   if (d[7] != 0) cout << "So to 2k la: " << d[7] << '\n';
  35.   if (d[8] != 0) cout << "So to 1k la: " << d[8] << '\n';
  36.   return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement