bycj.net
当前位置:首页 >> C语言 输入一个实数x,计算多项式x (x^2)/2! (x^3)/... >>

C语言 输入一个实数x,计算多项式x (x^2)/2! (x^3)/...

错误很多.请仔细比对,找出修改之处:#include#include int main() { double x,t,s=0; double f(double n); scanf("%lf",&x); while((t=f(x))>=1e-5) { s=s+t; } printf("%.3lf\n",s); system("pause"); return 0; } double f(double n) { int j; double item,a,b=1.0; static int i=1; a=pow(n,i); for(j=1;j { b=b*j; } i++; item=a/b; return item; }

#include#includeint main(){ double x; scanf("%f",&x); int i = 2; double tmp = x, result = x; while (tmp >= pow(10, -5)) { tmp = pow(x, i); for (int k = 1; k 评论0 0 0

#include <stdio.h> int main() { int n, i; float x, t = 1.0, s = 0.0; scanf("%f %d", &x, &n); for (i = 1; i <= n; i ++) { t *= x; s += t; } printf("%f\n", s); }

#include <stdio.h>#include <math.h> void main() { double x,s=0,m; long i=1,n=1; m=x=1.5; while(m>0.00001) { n*=i; m=pow(x,i); m/=n; s+=m; i++; } printf("X+X^2/2!+X^3/3!(X=1.5)=%lf",s); }

var a,b:qword;i,x:integer;c,t,s:real; begin readln(x); t:=1; for i:=1 to 10 do t:=t/10; a:=1;b:=1;s:=1;i:=0;c:=1; while c>=t do begin i:=i+1; a:=a*x; b:=b*i; c:=a/b; s:=s+c; end; writeln(s); end.

#include#include#include using namespace std;int

2 4 6是偶数递增吗?要是这样的话,那也不难float x,s=1;int i,t=2;for(i=2;pow(x,i)/t

x^7+1=(1+x)(1-x+x^2-x^3+x^4-x^5+x^6)

#include long factorial(long m){ assert(m>=0); if(m return 1; m=m*factorial(m-1); return m; } long exponent(long x, long e){ long i = 0; long value = 1; for(i; i value *= x; } return value; } float get(long x, long n){ long i=0; float value = 0.0; for(i; i value += (

先加入一条调试用的#include <stdio.h> void main() { float tn,x,i,sn=0,n,k=1; printf("请输入x,n:"); scanf("%f,%f",&x,&n); for(i=1;i<=n;i++) { tn=x/k; sn=sn+tn; k=k+2; x=x*x; /* 插入一条输出的调试用 */ printf("tn=%f, sn=%f, k=%f, x=%f\n", tn,

相关文档
ydzf.net | zxqk.net | mtwm.net | qmbl.net | gyzld.cn | 网站首页 | 网站地图
All rights reserved Powered by www.bycj.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com