下列给定程序中,函数fun()的功能是:根据以下公式求n的值,并作为函数值返回。例如,给指定精度的变
下列给定程序中,函数fun()的功能是:根据以下公式求n的值,并作为函数值返回。例如,给指定精度的变量eps输入 0.0005时,应当输出Pi=3.140578。n/2=1+1/3+1/3*2/5+1/3*2/5*3/7+1/3*2/5*3/7*4/9……请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio.h>include <stdio.h>include <math.h>double fun(double eps){double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
n/2=1+1/3+1/3*2/5+1/3*2/5*3/7+1/3*2/5*3/7*4/9……请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio.h>include <stdio.h>include <math.h>double fun(double eps){double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio.h>include <stdio.h>include <math.h>double fun(double eps){double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio.h>include <stdio.h>include <math.h>double fun(double eps){double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
试题程序:include <conio.h>include <stdio.h>include <math.h>double fun(double eps){double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
include <conio.h>include <stdio.h>include <math.h>double fun(double eps){double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
include <stdio.h>include <math.h>double fun(double eps){double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
include <math.h>double fun(double eps){double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
double fun(double eps){double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
{double s,t; int n=t;s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
s=0.0;/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
/*************found**************/t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
t=1;/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
/*************found**************/while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
while(t>eps){ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
{ s+=t;t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
t=t*n/(2*n+1);n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
n++;}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
}/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
/*************found**************/return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
return (s);}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
}main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
main(){ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
{ double x;printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
printf("\nPlease enter a precision: ");scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
scanf("%1f",&x);printf("\nPi=%1f\n ",fun(x));}
printf("\nPi=%1f\n ",fun(x));}
}
点击查看答案