Kobe___Bryant 2016-04-23 07:46 采纳率: 0%
浏览 3553

为什么我这个c++程序运行后直接关掉了窗口,就是应该运行出来了,但是还没来得及看结果就被自动关了

程序代码如下:
#include "stdafx.h"
#include
#include

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
double daphne = 100.0;
double cleo = 100.0;
const double rate_1 = 0.1;
const double rate_2 = 0.05;
double year = 0;
double temp = cleo - daphne;
while (temp <= 0)
{
year++;
daphne = daphne + daphne*rate_1*year;
double k = pow(1 + rate_1, year);
cleo = cleo*k;
temp = cleo - daphne;
}

cout << "after " << year << " years, cleo has more money than daphne! " << endl;
cout << "the money of daphne is: " << daphne << endl;
cout << "the money of cleo is: " << cleo << endl;
return 0;

}
求解答!!谢谢大神

  • 写回答

4条回答

  • Mokoa 2016-04-23 10:20
    关注

    在return 0;前面加system("pause");让程序暂停。不然运行完直接就结束掉了

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料