Advertisement
kolioi

Coins (w/o array)

Apr 27th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     float money;
  8.     cin >> money;
  9.  
  10.     int amount = (int)money;
  11.  
  12.     int count = 0, n = 0;
  13.     n = amount / 2;
  14.     count += n;
  15.  
  16.     count += amount - n * 2;
  17.  
  18.     amount = money * 100 - amount * 100;
  19.  
  20.     n = amount / 50;
  21.     count += n;
  22.     amount -= n * 50;
  23.  
  24.     n = amount / 20;
  25.     count += n;
  26.     amount -= n * 20;
  27.  
  28.     n = amount / 10;
  29.     count += n;
  30.     amount -= n * 10;
  31.  
  32.     n = amount / 5;
  33.     count += n;
  34.     amount -= n * 5;
  35.  
  36.     n = amount / 2;
  37.     count += n;
  38.     amount -= n * 2;
  39.  
  40.     count += amount;
  41.  
  42.     cout << count << '\n';
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement