Advertisement
konoha279

Câu 2

Feb 20th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int n = 3;
  4. void input(int a[100][100])
  5. {
  6.     for (int i = 0; i < n; i++)
  7.     {
  8.         for (int j = 0; j < n; j++)
  9.         {
  10.             cout << "a[" << i << "][" << j << "]= ";
  11.             cin >> a[i][j];
  12.         }
  13.     }
  14. }
  15. void output(int a[100][100])
  16. {
  17.     for (int i = 0; i < n; i++)
  18.     {
  19.         for (int j = 0; j < n; j++)
  20.         {
  21.             cout << a[i][j]<<" ";
  22.         }
  23.         cout << endl;
  24.     }
  25. }
  26. void quay(int a[100][100])
  27. {
  28.     int temp[100][100];
  29.     int tam = n - 1;
  30.     for (int i = 0; i < n; i++)
  31.     {
  32.         for (int j = 0; j < n; j++)
  33.         {
  34.             temp[j][tam] = a[i][j];
  35.         }
  36.         tam--;
  37.     }
  38.     output(temp);
  39. }
  40. int main()
  41. {
  42.     int b[100][100];
  43.     input(b);
  44.     cout << "truoc khi quay: " << endl;
  45.     output(b);
  46.     cout << "sau khi quay: " << endl;
  47.     quay(b);
  48.     system("pause");
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement