我刚开始学习 C++ 编程。我的程序运行完美,但当用户输入 sa 字符并按下回车键时,我还需要关闭它。我不知道应该怎么做。任何帮助将不胜感激。到目前为止,我的代码是(运行良好):
#include <iostream>
using namespace std;
int main()
{
int money_spent, money_tendered;
cout << "Enter the total amount spent: \n";
cin >> money_spent;
cout << "Enter the amount tendered: \n";
cin >> money_tendered;
int balance = money_tendered - money_spent;
int ten_bills = balance / 1000;
balance = balance % 1000;
int five_bills = balance / 500;
balance = balance % 500;
int dollar_coins = balance / 100;
balance = balance % 100;
int quater_coins = balance / 25;
balance = balance % 25;
int dimes = balance / 10;
balance = balance % 10;
int nickels = balance / 5;
balance = balance % 5;
int pennies = balance;
cout << " \n \n"
<< "Your change is: \n"
<< ten_bills << " tenn dollar bill(s). \n"
<< five_bills << " five dollar bill(s). \n"
<< dollar_coins << " one dollar coin(s). \n"
<< quater_coins << " quater(s). \n"
<< dimes << " dime(s). \n"
<< nickels << " nickel(s). \n"
<< pennies << " pennie(s). \n";
return 0;
}