/* Solve the equation micro_lee using the string truncation method */
# Include <stdio. h>
# Include <string. h>
# Include <math. h>
Void asterisk_triangle (int n );
Float F (float X)
{
Return x * (X-5) + 16)-80;
}
Float xpoint (float X1, float x2)
{
Return (x1 * F (X2)-X2 * F (X1)/(f (X2)-f (X1 ));
}
Float root (float X1, float x2)
{
Float X, Y, Y1, Y2;
Y1 = f (X1 );
Y2 = f (X2 );
Do {
X = xpoint (x1, x2 );
Y = f (x );
If (y * Y1> 0)
{
Y1 = y;
X1 = X;
}
Else
{
Y2 = y;
X2 = X;
}
} While (FABS (y) >=0.0001 );
Return (X );
}
Int main ()
{
Float x1, x2, F1, F2, X;
Do {
Printf ("input x1, x2:/N ");
Scanf ("% F, % F", & X1, & x2 );
F1 = f (X1 );
F2 = f (X2 );
} While (F1 * F2> = 0 );
X = root (x1, x2 );
Printf ("A root is % 8.4f/n", X );
Return 0;
}
Void asterisk_triangle (int n)
{
Int I, J, K, num = 0;
For (I = 1; I <= N; I ++)
{
Num = (2 * i-1)> n? 2 * (N + 1-I)-1: 2 * I-1;
For (k = 1; k <= (n-num)/2; k ++)
Printf ("");
For (j = 1; j <= num; j ++)
Printf ("*");
Printf ("/N ");
}
}