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 hang, int cot)
- {
- for (int i = 0; i <= hang - 1; i++)
- {
- for (int j = 0; j <= cot - 1; j++)
- {
- cout << endl;
- for (int k = hang - 1; k >= 0; k--)
- {
- b[j][i] = a[k][j];
- cout << b[j][i] << " ";
- }
- }
- }
- }
- 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 );
- cout << endl;
- PrintMatrix(b, bRow, bColumn);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement