?? sample5_1.cs
字號:
/*
* 示例程序Sample5_1: NLEquations類的求非線性方程實根的對分法
*/
using System;
using CSharpAlgorithm.Algorithm;
namespace CSharpAlgorithm.Sample
{
class Class1
{
// 建立NLEquation的子類,在其中重載函數func
class NLEq : NLEquations
{
protected override double Func(double x)
{
double z = (((((x-5.0)*x+3.0)*x+1.0)*x-7.0)*x+7.0)*x-20.0;
return z;
}
}
[STAThread]
static void Main(string[] args)
{
// 求解
NLEq nleq = new NLEq();
double[] x = new double[6];
int n = nleq.GetRootBisect(6, x, -2, 5, 0.2, 0.0001);
Console.WriteLine("求得如下" + n + "個根:");
for (int i=0; i<=n-1; i++)
{
Console.WriteLine(x[i]);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -