迭代解方程
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <time.h>
#include <algorithm>
using namespace std;
struct foo{
char d;
};
struct s
{ int x:3;
int y:4;
int z:5;
double a;
};
#include <stdio.h>
void main()
{
int N;
cin >> N;
float x= 1.0;
float x0;
float f;
float f1;
do
{
x0 = x;
f = x0 * x0 - N;
f1 = 2 * x0;
x = x0- f/f1;
}
while (fabs(x -x0) >= 1e-5);
cout << x <<endl;
}
一切源于对计算机的热爱

浙公网安备 33010602011771号