#include<iostream> using namespace std; void main() { float sum=0; float t=1.0,x,i=1,n=1.0,N,j=1; cout<<"请输入一个X的值"<<endl; cin>>x; cout<<"输入一个N"<<endl; cin>>N; while(i<=N) { sum=sum+t; j=j*x; t=j/n; i++; n=n*i; } cout<<"前"<<N<<"项和为:"<<sum; }