5.4

#define  _CRT_SECURE_NO_WARNINGS 
#include<iostream>
using namespace std;
int main()
{
	const double Simple_interest = 0.10;//Daphne投的单利
	const double Compound_interest = 0.05;//Cleo投的复利
	const int Primary_deposite = 100;//原始存款
	double Celo_deposite=100;//Cleo的初年资金
	double Daphne_deposite = 100;//Daphne的初年资金
	int i;
	
	for (i = 0; Celo_deposite<=Daphne_deposite; i++)
	{
		Daphne_deposite += Simple_interest*Primary_deposite;
		Celo_deposite += (Compound_interest*Celo_deposite);
	}
	cout << "After " << i<< " years,Celo will beyonds Daphne.And now investment value for Daphne and Celo is " << Daphne_deposite << " and " << Celo_deposite;
	return 0;
	
}

你可能感兴趣的:(C++)