输入精度e 和实数x,用下列公式求cos x 的近似值,精确到最后一项的绝对值小于e#include#includedouble funcos(double e,double x);int main(void){\x05double e,x;\x05printf("e:");scanf("%lf",&e);printf("x:");\x05scanf("%lf",&x);\x05printf("cos(x)=%.3f",funcos(e,x));\x05\x05return 0;}double funcos(double e,double x){\x05int i,a,b;\x05double sum,c;\x05sum=0.0;\x05c=1.0;\x05\x05i=0,a=1;\x05while(c>=e)\x05{\x05\x05if(i!=0)\x05\x05{\x05\x05\x05a=b=1;\x05\x05\x05for(b=1;b
问题描述:
输入精度e 和实数x,用下列公式求cos x 的近似值,精确到最后一项的绝对值小于e
#include
#include
double funcos(double e,double x);
int main(void)
{
\x05double e,x;
\x05printf("e:");
scanf("%lf",&e);
printf("x:");
\x05scanf("%lf",&x);
\x05printf("cos(x)=%.3f",funcos(e,x));
\x05
\x05return 0;
}
double funcos(double e,double x)
{
\x05int i,a,b;
\x05double sum,c;
\x05sum=0.0;
\x05c=1.0;
\x05
\x05i=0,a=1;
\x05while(c>=e)
\x05{
\x05\x05if(i!=0)
\x05\x05{
\x05\x05\x05a=b=1;
\x05\x05\x05for(b=1;b
答