题目内容
下面的程序是用递归算法求a的平方根。求平方根的迭代公式如下:X1=(X0+a/X0)/2,要求迭代精度不超过0.00001。#include #include double mysqrt( doublea, double x0 ){double x1, y;x1 = ;if( fabs(x1-x0)>0.00001 )y= mysqrt( );elsey = x1;return(y );}int main(){double x;printf("Enter x: ");scanf("%lf", &x);printf("Thesqrt of %lf=%lf\n", x, mysqrt( x, 1.0) );return0;}
查看答案
搜索结果不匹配?点我反馈