//追赶法解方程组Pursue.cpp#include #include #include using namespace std;class SolutionEquations{private: vector a; vector b; vector c; vector f; vector x; public: void setABCF(vector in_a, vector in_b, vector in_c, vector in_f) { a = in_a; b = in_b; c = in_c; f = in_f; } //追赶法解方程组 vector & Pursue() { vector bita; vector y; int n = f.size(); bita.push_back(c.at(0)/b.at(0)); y.push_back(f.at(0)/b.at(0)); for (int i=1; i =0; i--,k++) { double tmp = y.at(i)-bita.at(i)*x.at(k); x.push_back(tmp); } reverse(x.begin(),x.end()); return x; }};int main(){ SolutionEquations solution; vector a; vector b; vector c; vector f; a.push_back(0); a.push_back(-1); a.push_back(-2); a.push_back(-3); b.push_back(2); b.push_back(3); b.push_back(4); b.push_back(5); c.push_back(-1); c.push_back(-2); c.push_back(-3); f.push_back(6); f.push_back(1); f.push_back(-2); f.push_back(1); solution.setABCF(a,b,c,f); vector x = solution.Pursue(); for (int i=0; i