invest.cpp

来自「C++ primer plus第五章编程练习的代码」· C++ 代码 · 共 24 行

CPP
24
字号

#include <iostream>
 
int main()
{
	using namespace std;

	double Daphne=100;
	double Cloe=100;
	int year=1;
	do
	{
		Daphne=Daphne+100*0.1;
		Cloe=Cloe+Cloe*0.05;
		year++;
	}while(Cloe<Daphne);
	cout<<year<<" year later Cloe have more money than Daphne!"<<endl;
	cout<<"Cloe have money:"<<Cloe<<endl;
	cout<<"Daphne have money:"<<Daphne<<endl;

	system("pause");
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?