// This program is based on the .NET platform, the compilation environment is Microsoft Visual C .NET
/ / For the modification of the VC 6.0 platform, only the stdafx.h will be replaced with iostream.h, then remove "Using Namespace STD" in the main function.
// See Blog.9cbs.Net/chinley for details.
/ / # include "stdafx.h"
#include "iostream.h"
#include "math.h"
// using namespace std;
Double du, DV;
// Solve a secondary equation
Void Solu_w (Double B, Double C)
{
Double Tem, Tem1;
TEM1 = B * B-4 * C;
Double M, N;
M = (- 1) * B / 2;
// Judgment is a real solution or a complex solution.
IF (Tem1> = 0)
{
TEM = SQRT (TEM1);
N = TEM / 2;
COUT << "/ n Equation root is:" << '/ n' << "/ t x1 =" << m n << '/ n' << "/ t x2 =" << MN << endl ;
}
Else
{
TEM = SQRT ((- 1) * TEM1);
N = TEM / 2;
Cout << "/ n equation root is:" << '/ n' << "/ t x1 =" << m << " " << n << "i" << '/ n' << " / T x2 = "<< m <<" - "<< n <<" i "<< '/ n' << endl;
}
}
// Solve the binary first equation, where (A, B, C), (D, E, F) are two coefficients of the equation group, once a constant term, X coefficient, and y coefficient.
Void get_du_dv (Double A, Double B, Double C, Double D, Double E, DOUBLE F)
{
DV = (B * D-A * E) / (c * e-b * f);
DU = (C * D-a * f) / (b * f-c * e);
}
void main ()
{
Cout << "See Blog.9cbs.Net/chinley./n" for details.
INT T1, T2, T3;
Double * a;
Cout << "Enter the order:"; // Specific reasons to be checked
CIN >> T1;
A = new double [t1];
T3 = T2 = T1;
COUT << "Enter the coefficients of each item: / n";
For (T1; T1> = 0; T1 -)
{
COUT << "/ ta [" << T1 << "=";
CIN >> A [T1];
}
COUT << "equation is: / N / t";
For (t2; t2> = 1; t2 -)
{
COUT << a [t2] << "x ^" << T2 << " ";
COUT << a [0] << "= 0" << endl;
Double U, V;
COUT << "The constant item of the input factor and the one-time coefficient:" << Endl;
COUT << "/ t u =";
CIN >> U;
COUT << "/ t v =";
CIN >> V;
COUT << "/ n factor type is: / n / t w (x) =" << "x ^ 2 " << u << "(x) " << V << endl;
Double P [98], R0, R1;
Cout << "/ n input correction number:";
Int count1;
CIN >> count1;
For (count1; count1> = 0; count1 -)
{
P [T3] = P [T3-1] = 0;
INT T4 = T3-2;
For (T4; T4> = 0; T4 -)
{
P [T4] = a [T4 2] -P [T4 2] * V-P [T4 1] * u;
R0 = a [1] -V * p [1] -u * p [0];
R1 = a [0] -V * p [0];
// The following line is added in the program, the problem will result in: If the number of corrections is too large, the program runtime is prolonged, and the main time is consumed on the screen display.
// cout << "/ TP (x) =" << p [2] << "(x * x) " << p [1] << "(x) " << p [0] < <"= 0" << ENDL;
Double R0V, R1V, R0U, R1U;
R0V = u * p [2] -p [1];
R1V = v * p [2] -p [0];
R0U = R1V-U * R0V;
R1U = (- 1) * V * R0V;
GET_DU_DV (R0, R0U, R0V, R1, R1U, R1V);
}
u = u du;
v = V DV;
}
Solu_w (u, v);
}