#include<stdio.h> #include<math.h> int main(){ int i,s=0,a,k,n,m,h,l,min,max; double x1=1,x2,w; int c[100][100]; scanf("%lf",&w); do{ x2=x1; x1 = (x2+w/x2)/2; }while(fabs(x2-x1)>=0.00001); printf("%.3lf",x2); return 0; } |
Double click to view unformatted code.