Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Some coins and vending machine

JOHNYTHEWINNER Feb 14th, 2020 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6. #include <string>
  7.  
  8. int main()
  9. {
  10.     double sum;
  11.     cin >> sum;
  12.     sum = round(sum * 100);
  13.     int twoleva = 200;
  14.     int oneleva = 100;
  15.     int fiftycoins = 50;
  16.     int twentycoins = 20;
  17.     int tencoins = 10;
  18.     int fivecoins = 5;
  19.     int twocoins = 2;
  20.     int onecoin = 1;
  21.     int counter = 0;
  22.     while (sum > 0) {
  23.         while (sum - twoleva >= 0) {
  24.             sum -= twoleva;
  25.             counter++;
  26.         }
  27.         while (sum - oneleva >= 0) {
  28.             sum -= oneleva;
  29.             counter++;
  30.         }
  31.         while (sum - fiftycoins >= 0) {
  32.             sum -= fiftycoins;
  33.             counter++;
  34.         }
  35.         while (sum - twentycoins >= 0) {
  36.             sum -= twentycoins;
  37.             counter++;
  38.         }
  39.         while (sum - tencoins >= 0) {
  40.             sum -= tencoins;
  41.             counter++;
  42.         }
  43.         while (sum - fivecoins >= 0) {
  44.             sum -= fivecoins;
  45.             counter++;
  46.         }
  47.         while (sum - twocoins >= 0) {
  48.             sum -= twocoins;
  49.             counter++;
  50.         }
  51.         while (sum - onecoin >= 0) {
  52.             sum -= onecoin;
  53.             counter++;
  54.         }
  55.     }
  56.     cout << counter << endl;
  57.     return 0;
  58. }
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