Advertisement
mr1302

Untitled

Dec 9th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     const int money[9] = {5000, 1000, 500, 100, 50, 10, 5, 2, 1};
  6.     int arr[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  7.     int k;
  8.     cin >> k;
  9.  
  10.     for (int i = 0; i < 9; ++i) {
  11.         arr[i] = k / money[i];
  12.         k %= money[i];
  13.     }
  14.  
  15.     for (int i = 0; i < 9; ++i) {
  16.         cout << arr[i] << " ";
  17.     }
  18.     cout << endl;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement