while循环中改变变量的问题

如果这样的写法是错的,那怎样才能做到题目要求的效果呢?图片图片图片

 while(Cleo_profit<Daphne_profit)
100会比100小吗?不成立,当然不进去了。

上面程序那里我写错了,应该是*=1.05,但是结果仍然是那样

while(Cleo_profit<=Daphne_profit)

#include
using namespace std;
int main()
{
double Daphne=100.0;
double Cleo=100.0;
double rate_daphne=0.1;
double rate_cleo=0.05;
int year=1;
//第一年取值。
Daphne=Daphne*(1+rate_daphne);
Cleo=Cleo*(1+rate_cleo);
while(Daphne>Cleo)
{
year++;
Daphne=100*(1+rate_daphne*year);
Cleo=Cleo*(1+rate_cleo);
}
cout<<"year:"<<year<<endl;
cout<<"Daphne's Money:"<<Daphne<<endl;
cout<<"Cleo's Money:"<<Cleo<<endl;
return 0;
}

while(Cleo_profit<Daphne_profit)
100会比100小吗?不成立,当然不进去了。