вот тебе 3 над остальными думаю
int factorial(int n)
{
if(n>1)
return n*factorial(n-1);
}
else
return 1;
1)
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void print_matrix(int **matrix, const int n)
for (int jjj = 0; jjj < n; jjj++)
for (int kkk = 0; kkk < n; kkk++)
cout << matrix[jjj][kkk] << " ";
cout << endl;
};
void fill_matrix(int **matrix, const int n)
int min = 0;
int max = 100;
matrix[jjj][kkk] = rand() % (max - min + 1) + min;
void transform_matrix(int **matrix1, int **matrix2, const int n)
int xswap = rand() % n;
int yswap = rand() % n;
cout << "\n"
<< xswap << " " << yswap << endl;
for (int jjj = xswap; jjj < n; jjj++)
matrix2[jjj][kkk] = matrix1[jjj - xswap][kkk];
for (int jjj = 0; jjj < xswap; jjj++)
matrix2[jjj][kkk] = matrix1[jjj + n - xswap][kkk];
for (int kkk = yswap; kkk < n; kkk++)
matrix2[jjj][kkk] = matrix1[jjj][kkk - yswap];
for (int kkk = 0; kkk < yswap; kkk++)
matrix2[jjj][kkk] = matrix1[jjj][kkk + n - yswap];
int main()
srand(time(0));
const int n = 5;
int **matrix1 = new int *[n];
matrix1[jjj] = new int[n];
fill_matrix(matrix1, n);
print_matrix(matrix1, n);
int **matrix2 = new int *[n];
matrix2[jjj] = new int[n];
transform_matrix(matrix1, matrix2, n);
print_matrix(matrix2, n);
вот тебе 3 над остальными думаю
int factorial(int n)
{
if(n>1)
{
return n*factorial(n-1);
}
else
{
return 1;
}
}
1)
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void print_matrix(int **matrix, const int n)
{
for (int jjj = 0; jjj < n; jjj++)
{
for (int kkk = 0; kkk < n; kkk++)
cout << matrix[jjj][kkk] << " ";
cout << endl;
};
}
void fill_matrix(int **matrix, const int n)
{
int min = 0;
int max = 100;
for (int jjj = 0; jjj < n; jjj++)
for (int kkk = 0; kkk < n; kkk++)
matrix[jjj][kkk] = rand() % (max - min + 1) + min;
}
void transform_matrix(int **matrix1, int **matrix2, const int n)
{
int xswap = rand() % n;
int yswap = rand() % n;
cout << "\n"
<< xswap << " " << yswap << endl;
for (int jjj = xswap; jjj < n; jjj++)
for (int kkk = 0; kkk < n; kkk++)
matrix2[jjj][kkk] = matrix1[jjj - xswap][kkk];
for (int jjj = 0; jjj < xswap; jjj++)
for (int kkk = 0; kkk < n; kkk++)
matrix2[jjj][kkk] = matrix1[jjj + n - xswap][kkk];
for (int jjj = 0; jjj < n; jjj++)
for (int kkk = yswap; kkk < n; kkk++)
matrix2[jjj][kkk] = matrix1[jjj][kkk - yswap];
for (int jjj = 0; jjj < n; jjj++)
for (int kkk = 0; kkk < yswap; kkk++)
matrix2[jjj][kkk] = matrix1[jjj][kkk + n - yswap];
}
int main()
{
srand(time(0));
const int n = 5;
int **matrix1 = new int *[n];
for (int jjj = 0; jjj < n; jjj++)
matrix1[jjj] = new int[n];
fill_matrix(matrix1, n);
print_matrix(matrix1, n);
int **matrix2 = new int *[n];
for (int jjj = 0; jjj < n; jjj++)
matrix2[jjj] = new int[n];
transform_matrix(matrix1, matrix2, n);
cout << endl;
print_matrix(matrix2, n);
}