fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. void f(double&x1,double&x2,double&x3,double&x4)
  7. {
  8. x1 = 0.32*x1 - 0.18*x2 + 0.02*x3 + 0.21*x4 + 1.83;
  9. x2 = 0.16*x1 + 0.12*x2 - 0.14*x3 + 0.27*x4 - 0.65;
  10. x3 = 0.37*x1 + 0.27*x2 - 0.02*x3 - 0.24*x4 + 2.23;
  11. x4 = 0.12*x1 + 0.21*x2 - 0.18*x3 + 0.25*x4 - 1.13;
  12. }
  13.  
  14. int main()
  15. {
  16. const double eps = 0.001;
  17.  
  18. double x1 = 0, x2 = 0, x3 = 0, x4 = 0, y1 = 1, y2 = 1, y3 = 1, y4 = 1;
  19.  
  20. for(;abs(x1-y1) > eps || abs(x2-y2) > eps || abs(x3-y3) > eps || abs(x4-y4) > eps;)
  21. {
  22. y1 = x1; y2 = x2; y3 = x3; y4 = x4;
  23. cout << setw(10) << x1 << setw(10) << x2 << setw(10) << x3 << setw(10) << x4 << endl;
  24. f(x1,x2,x3,x4);
  25.  
  26. }
  27.  
  28. }
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
         0         0         0         0
      1.83   -0.3572   2.81066  -1.49133
   2.22293  -1.13335   3.04819  -2.02276
   2.38152  -1.37785   3.16364  -2.20871
   2.43954  -1.46428   3.20409  -2.27367
   2.46084  -1.49444   3.21861   -2.2963
   2.46862  -1.50496   3.22379  -2.30416
   2.47145  -1.50862   3.22563  -2.30689
   2.47248  -1.50989   3.22629  -2.30783