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 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧