提示:(1)需要计算出30天后陌生人给了百万富翁多少钱,百万富翁给了陌生人多少钱,然后才能做出判断;(2)想要看得清楚,可以选择列出每一天双方交易获得的钱数。
题目来源:贪财的富翁
#include <iostream>
#include <math.h>
using namespace std;
//等比数列的应用
void main()
{
int days = 1;
double rich2X = 0.01;
double x2Rich = 1.0e5;
int q = 2;
cout << "Please input the final days: " << endl;
cin >> days;
cout << "Until today X should give: " << days * x2Rich << " in total" << endl;
double an = rich2X*pow(2.0,days - 1);
cout << "Today Rich should give: " << an << " to X" << endl;
double sum= 0.0;
sum = rich2X * (1 - pow(double(q),days))/(1 - q);
cout << "Until today Rich should give: " << sum << " to X in total" << endl;
system("pause");
}