Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /*
- a[][100]: matrix a
- aRow: row number of matrix a
- aColumn: column number of matrix a
- */
- void ImportMaxtrix(int a[][100], int aRow, int aColumn)
- {
- for (int i = 0; i < aRow; i++)
- for (int j = 0; j < aColumn; j++)
- {
- cout<<"A["<<i<<"]["<<j<<"] = ";
- cin >> a[i][j];
- }
- }
- void PrintMatrix(int a[][100], int aRow, int aColumn)
- {
- for (int i = 0; i < aRow; i++)
- {
- for (int j = 0; j < aColumn; j++)
- {
- cout<< a[i][j];
- cout << " ";
- }
- cout << endl;
- }
- }
- //Rotate matrix 90 degree
- void Rotate90(int a[][100], int b[][100], int aRow, int aColumn, int bRow, int bComlumn)
- {
- int t = 2;
- for (int j = 0; j < aColumn; j++)
- {
- int k = 0;
- for (int i = 0; i < aRow; i++)
- {
- b[i][t] = a[j][k];
- k++;
- }
- t--;
- }
- }
- int main() {
- int a[100][100];
- int b[100][100];
- int aRow= 3, aColumn = 3, bRow = 3, bColumn = 3;
- ImportMaxtrix(a, aRow, aColumn);
- PrintMatrix(a, aRow, aColumn);
- Rotate90(a, b, aRow, aColumn, bRow, bColumn);
- cout << endl;
- PrintMatrix(b, bRow, bColumn);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement