Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1.     cout << "It number = " << k << endl;
  2.     for (int i = 0; i < n; i++)
  3.         cout << "x[" << i << "] = " << P[k][i] << " " << endl;
  4.     double sum;
  5.     do
  6.     {
  7.         k++;
  8.         for (int i = 0; i < n; i++)
  9.         {
  10.             P[k][i] = P[k - 1][i];
  11.         }
  12.  
  13.         for (int i = 0; i < n; i++)
  14.         {
  15.             P[k][i] = 0;
  16.             for (int j = 0; j < m; j++)
  17.             {
  18.                 if (i == j)
  19.                     P[k][i] += A1[i][j];
  20.                 else
  21.                     P[k][i] += A1[i][j] * P[k][j];
  22.             }
  23.         }
  24.  
  25.         cout << "It number = " << k << endl;
  26.         for (int i = 0; i < n; i++)
  27.             cout << "x[" << i << "] = " << P[k][i] << " " << endl;
  28.  
  29.         sum = 0;
  30.         for (int i = 0; i < n; i++)
  31.         {
  32.             sum += (P[k - 1][i] - P[k][i]) * (P[k - 1][i] - P[k][i]);
  33.         }
  34.     } while (pow(sum, 0.5) >= e);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement