style: format code

This commit is contained in:
yanglbme
2019-08-21 10:10:08 +08:00
parent abc0d365de
commit 69ddc9fc52
101 changed files with 3154 additions and 2984 deletions

View File

@@ -1,53 +1,53 @@
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include <iostream.h>
#include <conio.h>
#include <math.h>
float eq(float i)
{
return (pow(i,3)-(4*i)-9); // original equation
return (pow(i, 3) - (4 * i) - 9); // original equation
}
void main()
{
float a,b,x,z;
float a, b, x, z;
clrscr();
for(int i=0;i<100;i++)
for (int i = 0; i < 100; i++)
{
z=eq(i);
if(z>=0)
z = eq(i);
if (z >= 0)
{
b=i;
a=--i;
b = i;
a = --i;
goto START;
}
}
START:
START:
cout<<"\nFirst initial: "<<a;
cout<<"\nSecond initial: "<<b;
for(i=0;i<100;i++)
cout << "\nFirst initial: " << a;
cout << "\nSecond initial: " << b;
for (i = 0; i < 100; i++)
{
x=(a+b)/2;
z=eq(x);
cout<<"\n\nz: "<<z<<"\t["<<a<<" , "<<b<<" | Bisect: "<<x<<"]";
x = (a + b) / 2;
z = eq(x);
cout << "\n\nz: " << z << "\t[" << a << " , " << b << " | Bisect: " << x << "]";
if(z < 0)
if (z < 0)
{
a=x;
a = x;
}
else
{
b=x;
b = x;
}
if(z > 0 && z<0.0009) // stoping criteria
if (z > 0 && z < 0.0009) // stoping criteria
{
goto END;
}
}
END:
cout<<"\n\nRoot: "<<x;
END:
cout << "\n\nRoot: " << x;
getch();
}