解题思路:
注意事项:
参考代码:
#include <cstdio> using namespace std; double f(double ); double mp(double ,double ); int main(){ double x,n,s(0); scanf("%lf %lf",&x,&n); for(int i=1;i<=int(n);i++){ if(!(i&1)) s=s-(mp(x,i)/f(i)); else s=s+(mp(x,i)/f(i)); } printf("%.4lf",s); return 0; } double f(double n){ double x=n; for(double i=n-1;i>0;i--) x*=i; return x; } double mp(double x,double n){ double a=x; for(double i=1;i<n;i++) a*=x; return a; }
0.0分
0 人评分