Start: Oct, 23, 2015 15:00:00
2015程序设计基础第三次作业
End: Nov, 28, 2015 23:59:00
Time elapsed:
Time remaining:

【C系列4.15】问题二:单参数函数 1983

Time Limit:  1 s      Memory Limit:   128 MB
Submission:556     AC:154     Score:1

Description

编写一个函数,该函数用迭代法求平方根。求平方根的迭代公式为:

其中a 是需要求平方根的数。(主函数代码部分已经写好,只需写函数部分,如果提交的不是c语言则需要提交全部代码)

#include<stdio.h>
#include<math.h>

double happy(double a);
double a;

int main() {
    while (scanf("%lf", &a) != EOF) {
        printf("%.6lf ", happy(a));
    }
    return 0;
}

Input

输入实数a。

Output

输出a的平方根。答案精确到10-6.

Samples

input
8
output
2.828427

Hint

特别需要注意当a=0的情况。