Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<ctime>
- using namespace std;
- void create_B(int A[10][10], int B[10][10], int n)
- {
- int k = 0, l = 0;
- for(int i = n - 1; i >= 0; i--)
- {
- for(int j = 0; j < n; j++)
- {
- B[k][l] = A[i][j];
- //printf("i = %d, j = %d, k = %d, l = %d\n", i,j,k,l);
- l++;
- }
- k++;
- l = 0;
- }
- }
- int main()
- {
- srand(time(NULL));
- int n, A[10][10], B[10][10];
- cin >> n;
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < n; j++)
- {
- A[i][j] = (rand() % 18) - 9;
- }
- }
- create_B(A, B, n);
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < n; j++)
- {
- if(i == n/2 && j == 0)
- {
- cout << "A = ";
- }
- else if(j == 0)
- {
- cout << " ";
- }
- cout << A[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < n; j++)
- {
- if(i == n/2 && j == 0)
- {
- cout << "B = ";
- }
- else if(j == 0)
- {
- cout << " ";
- }
- cout << B[i][j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement