1 条题解
-
0
C :
#include <stdio.h> #include <math.h> int main() { double a, x, y; scanf("%lf %lf", &a, &x); y = x + 1; while(fabs(x - y) >= 0.00001) { y = x; x = (y + a / y)/2.0; } printf("%.6lf\n", x); return 0; }
C++ :
#include<stdio.h> #include<math.h> int main() { float x0,x1,a; scanf("%f",&a); x1=a/2; do { x0=x1;x1=(x0+a/x0)/2; } while(fabs(x0-x1)>=0.00001); printf("%f\n",x1); }
- 1
信息
- ID
- 1776
- 时间
- 1000ms
- 内存
- 12MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者