第二个改成
#include <math.h>
#include <stdio.h>
main()
{float x,t,c
int a
scanf("%d",&a)
x=1
t=xx=(1.0/2)*(x+a/x)c=x-t
while(fabs(c)/x>1e-5)
{
t=xx=(1.0/2)*(x+a/x)c=x-t
}
printf("%f",x)
getch()
}
才会等价于第一个程序
第二个改成
#include <math.h>
#include <stdio.h>
main()
{float x,t,c
int a
scanf("%d",&a)
x=1
t=xx=(1.0/2)*(x+a/x)c=x-t
while(fabs(c)/x>1e-5)
{
t=xx=(1.0/2)*(x+a/x)c=x-t
}
printf("%f",x)
getch()
}
才会等价于第一个程序