change.cpp

来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C++ 代码 · 共 39 行

CPP
39
字号
#include <iostream>using namespace std;// make change in U.S. coins// Owen Astrachan, 03/17/99int main(){    int amount;    int quarters, dimes, nickels, pennies;    // input phase of program        cout << "make change in coins for what amount: ";    cin >> amount;    // calculate number of quarters, dimes, nickels, pennies    quarters = amount/25;    amount = amount - quarters*25;    dimes = amount/10;    amount = amount - dimes*10;    nickels = amount/5;    amount = amount - nickels*5;    pennies = amount;    // output phase of program        cout << "# quarters =\t" << quarters << endl;    cout << "# dimes =\t"    << dimes    << endl;    cout << "# nickels =\t"  << nickels  << endl;    cout << "# pennies =\t"  << pennies  << endl;    return 0;    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?