#include <iostream>
#include <math.h>
using namespace std;
#define N 4
int main()
{ int a[N][N], b;
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
a[i][j] = rand() % 10;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
cout << a[i][j] << " ";
cout << "\n";
}
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
{
b = a[i][j];
a[i][j] = a[j][i];
a[j][i] = b;
}
cout << "\n\n\n\n";
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
cout << a[i][j] << " ";
cout << "\n";
}
}
#include <math.h>
using namespace std;
#define N 4
int main()
{ int a[N][N], b;
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
a[i][j] = rand() % 10;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
cout << a[i][j] << " ";
cout << "\n";
}
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
{
b = a[i][j];
a[i][j] = a[j][i];
a[j][i] = b;
}
cout << "\n\n\n\n";
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
cout << a[i][j] << " ";
cout << "\n";
}
}
No comments:
Post a Comment