分析:按照题目要求敲就行了。
#include<iostream>
#include<iomanip>
#include<cmath>
using std::cout;
using std::cin;
using std::fixed;
using std::setprecision;
using std::pow;
int main()
{
int n=0;
double x = 0;
cin >>x>> n;
double result = 0;//记录结果
for (int i = 0; i <= n; ++i)
{
double num = 0;//记录每项数
for (int j = 0; j <= i; ++j)
{
num = pow(x, i);
}
result += num;
}
cout << fixed<<setprecision(2)<<result;
}