// Catch-up method for solving the equation group pursue. cpp # Include <iostream> # Include <Vector> # Include <Algorithm> Using Namespace STD; Class Solutionequations { Private : Vector < Double > A; vector < Double > B; vector < Double > C; vector < Double > F; vector < Double > X; Public : Void Setabcf (vector < Double > In_a, vector < Double > In_ B, vector < Double > In_c, vector < Double > In_f) { = In_a; B = In_ B; c = In_c; f = In_f ;} // Catch-up Method for Solving Equations Vector < Double > & Pursue () {Vector < Double > Bita; vector <Double > Y; Int N = F. Size (); bita. push_back (C. ( 0 )/B. ( 0 ); Y. push_back (F. ( 0 )/B. ( 0 )); For ( Int I = 1 ; I <n- 1 ; I ++){ Double Alpha = B. at (I)-A. at (I) * bita. At (I- 1 ); Double TMP = C. at (I )/ Alpha; bita. push_back (TMP); TMP = (F. at (I)-A. at (I) * Y. At (I- 1 ))/ Alpha; Y. push_back (TMP );} Double Alpha = B. At (n- 1 )-A. At (n- 1 ) * Bita. At (n- 2 ); Double TMP = (F. At (n- 1 )-A. At (n- 1 ) * Y. At (n- 2 ))/ Alpha; Y. push_back (TMP); X. push_back (Y. At (n - 1 )); For ( Int I = N- 2 , K = 0 ; 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 < Double > A; vector < Double > B; vector < Double >C; vector < Double > 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 < Double > X = Solution. Pursue (); For ( Int I = 0 ; I <X. Size (); I ++ ) {Cout < " X = " <X. at (I) <Endl ;}}