C++程序闪退问题
#include<iostream>#include<cmath>
using namespace std;
int main()
{
cout << "Enter yearly interest rate,for exmple 7.25:";
double annualInsterestRate;
cin >> annualInsterestRate;
double monthlyInsterestRate = annualInsterestRate/1200;
cout << "Enter number of years as an integer,for example 5:";
double number0fYears;
cin >> number0fYears;
cout << "Enter loan amount ,for exmple 120000.95:";
double loanAmount;
cin >> loanAmount;
double monthlyPayment = loanAmount*monthlyInsterestRate / (1 - 1 / pow(1 + monthlyInsterestRate, number0fYears * 12));
double totalPayment = monthlyPayment * number0fYears * 12;
monthlyPayment = static_cast<int>(monthlyPayment * 100) / 100.0;
totalPayment = static_cast<int>(totalPayment * 100) / 100.0;
cout << "The monthly payment is " << monthlyPayment<< endl << "The total payment is " << totalPayment << endl;
cin.get();
return 0;
}
分别输入3
5
1000
没有显示输出结果,为什么会直接闪退呀,加了cin.get()也没用