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");让程序暂停。不然运行完直接就结束掉了

    评论

报告相同问题?

悬赏问题

  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 如何提取csv文件中需要的列,将其整合为一篇完整文档,并进行jieba分词(语言-python)
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题