Advertisement
satriafu5710

Menampilkan Matriks Transpose C++

Dec 10th, 2021
1,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7.     int a[10][10], baris, kolom;
  8.  
  9.     cout << "\n\t Menampilkan Matriks Transpose \n\n";
  10.  
  11.     cout << " Inputkan Jumlah Baris : ";
  12.     cin >> baris;
  13.  
  14.     cout << " Inputkan Jumlah Kolom : ";
  15.     cin >> kolom;
  16.  
  17.     cout << endl;
  18.  
  19.     for (int i = 0; i < baris; i++)
  20.     {
  21.  
  22.         for (int j = 0; j < kolom; j++)
  23.         {
  24.  
  25.             cout << " Inputkan Data [ " << i << ", " << j << " ] : ";
  26.             cin >> a[i][j];
  27.         }
  28.     }
  29.  
  30.     cout << "\n Matriks sebelum di Transpose : \n\n";
  31.  
  32.     for (int i = 0; i < baris; i++)
  33.     {
  34.  
  35.         for (int j = 0; j < kolom; j++)
  36.         {
  37.  
  38.             cout << "   " << a[i][j] << "  ";
  39.         }
  40.  
  41.         cout << endl
  42.              << endl;
  43.     }
  44.  
  45.     cout << "\n Matriks setelah di Transpose : \n\n";
  46.  
  47.     for (int i = 0; i < baris; i++)
  48.     {
  49.  
  50.         for (int j = 0; j < kolom; j++)
  51.         {
  52.  
  53.             cout << "   " << a[j][i] << "  ";
  54.         }
  55.  
  56.         cout << endl
  57.              << endl;
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement