fun函数设置循环,当x0-x1的绝对值小于0.000001循环结束。
#include
<stdio.h>
#include
<math.h>
float
fun()
{float
x,n=0.0,root
while(root>=0.000001||root<=-0.000001)
{
x=n
n=cos(x)
root=x-n
}
root=n
return
root
}
void
main()
{
float
f=fun()
printf("root=%f\n",f)
}