daily pastebin goal
17%
SHARE
TWEET

05.Coins C++

Threed90 Oct 12th, 2018 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <math.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     double balance;
  11.  
  12.     cin >> balance;
  13.  
  14.     balance *= 100;
  15.  
  16.     int counter = 0;
  17.  
  18.     while ( (int)balance != 0)
  19.     {
  20.         if (balance >= 200)
  21.         {
  22.             balance -= 200;
  23.         }
  24.         else if (balance >= 100)
  25.         {
  26.             balance -= 100;
  27.         }
  28.         else if (balance >= 50)
  29.         {
  30.             balance -= 50;
  31.         }
  32.         else if (balance >= 20)
  33.         {
  34.             balance -= 20;
  35.         }
  36.         else if (balance >= 10)
  37.         {
  38.             balance -= 10;
  39.         }
  40.         else if (balance >= 5)
  41.         {
  42.             balance -= 5;
  43.         }
  44.         else if (balance >= 2)
  45.         {
  46.             balance -= 2;
  47.         }
  48.         else if (balance >= 1)
  49.         {
  50.             balance -= 1;
  51.         }
  52.         counter++;
  53.     }
  54.  
  55.     cout << counter << endl;
  56.     return 0;
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top