提示:(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");
}