1、(原创)利用克拉默法则求解多元一次方程组package zouyf.matrix;/* author zouyf 2008-4-7 本程序利用克拉默法则求解多元一次方程组*/public class GetMatrixprivate double savequot;/ 保存变量系数private double constquot;/ 保存常量系数private double saveResult;/ 保存解的集合public GetMatrix(double quot)int count = quot.length;savequot = new doublecountcount;constqu
2、ot = new doublecount;saveResult = new doublecount;int i = 0, j = 0;for (i = 0; i #include #include /本程序利用克拉默法则求解多元一次方程组using namespace std;class GetMatrixpublic:GetMatrix(vector quot);double getMatrixResult(vector input);vector getReplaceMatrix(int i);vector getResult();private:vector savequot;vecto
3、r constquot;vector saveResult;GetMatrix:GetMatrix(vector quot)int count = quot.size();savequot.resize(count);for (int i=0;i input)/ 递归的方法求得某个行列式的值if (input.size() = 2)/递归出口,为二阶行列式时,直接返回return input00 * input11 - input01 * input10; elseint iLength=input.size();vector temp(iLength);vector tempinput(iL
4、ength-1,vector(iLength-1);double result = 0;for (int i = 0; i GetMatrix:getReplaceMatrix(int i)/ 用常数系数替换相应的变量系数,得到新的行列式vector tempresult(savequot);for (int m = 0; m GetMatrix:getResult()double basic = 0;basic = getMatrixResult(savequot);/得到变量系数行列式的值if (abs(basic) temp(iLength,vector(iLength);for (int i = 0; i test(2,vector(3);for(int i=0;i uu(gm-getResult();/ 返回结果集for (int i = 0; i uu.size(); i+)coutuui endl;delete gm;gm=0;system(“pause“);return 0;