1 solutions
-
0
C :
#include<stdio.h> #include<math.h> int main(){ double x1 ,x2 , a; scanf("%lf",&a); x1=1; x2=(1.0/2)*(x1+a/x1); do{ x1=x2; x2=(1.0/2)*(x1+a/x1); }while(fabs(x2-x1)>=0.00001); printf("%.3lf",x2); return 0; }C++ :
#include "stdio.h" #include "math.h" int main(int argc, char* argv[]) { double a,x1,x2; while(~scanf("%lf",&a)) { x1=a/2; x2=(x1+a/x1)/2; while(fabs(x2-x1)>=0.00001) { x1=x2; x2=(x1+a/x1)/2; } printf("%.3lf",x2); } return 0; }Pascal :
Program TK1839; var x:longint; Begin read(x); writeln(sqrt(x):0:3); End.
- 1
Information
- ID
- 19307
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- (None)
- # Submissions
- 0
- Accepted
- 0
- Uploaded By