daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Nov 19th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int get(int i, int j, int n)
  2. {
  3.     int A[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
  4.     if (i <= j) return A[i * n + j];
  5.     else return A[j * n + i];
  6. }
  7.  
  8. int main()
  9. {
  10.     int n = 5;
  11.     int A[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
  12.     int C[5][5] = { { 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0 } };
  13.         for (int i = 0; i < n; i++)
  14.     {
  15.     for (int k = 0; k < n; k++)
  16.     {
  17.     for (int j = 0; j < n; j++)
  18.     {
  19.  
  20.         C[i][j] += (get(i, k, n) * get(k, j, n));
  21.  
  22.     }
  23.     }
  24.     }
  25.  
  26.     for (int i = 0; i < n; i++)
  27.     {
  28.         for (int j = 0; j < n; j++)
  29.         {
  30.             cout << setw(15) << C[i][j];
  31.         }
  32.         cout << endl;
  33.     }
  34.  
  35. return 0;
  36. }
RAW Paste Data
Top