1 solutions

  • 0
    @ 2025-11-5 19:02:19

    C++ :

    #include<iostream>
    #include<cmath>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	double a,x0,x1;
    	cin>>a;
    	x0=a/2;
    	x1=(x0+a/x0)/2;
    	while (fabs(x1-x0)>1e-5)
    	{
    		x0=x1;
    		x1=(x0+a/x0)/2;
    	}
    	printf("%.3lf\n",x1);
    	return 0;
    }
    
    • 1

    C语言程序设计教程(第三版)课后习题6.11

    Information

    ID
    19151
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    (None)
    # Submissions
    0
    Accepted
    0
    Uploaded By