procedure ArithMeanColumn(A: Matrix; C: integer); var i: byte; ArithMean: real; begin ArithMean := 0; for i := 0 to n - 1 do ArithMean := ArithMean + A[i, C - 1];
begin write('Введите n: '); readln(n); write('Введите m: '); readln(m); SetLength(A, n, m); randomize; for i := 0 to n - 1 do begin for j := 0 to m - 1 do begin A[i, j] := random(10); write(A[i, j]:10:3); end; writeln; end;
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);
}
type Matrix = array of array of real;
var
A: Matrix;
n, m, i, j, C: byte;
procedure ArithMeanColumn(A: Matrix; C: integer);
var
i: byte;
ArithMean: real;
begin
ArithMean := 0;
for i := 0 to n - 1 do
ArithMean := ArithMean + A[i, C - 1];
ArithMean := ArithMean / C;
writeln(ArithMean:10:3);
end;
begin
write('Введите n: ');
readln(n);
write('Введите m: ');
readln(m);
SetLength(A, n, m);
randomize;
for i := 0 to n - 1 do
begin
for j := 0 to m - 1 do
begin
A[i, j] := random(10);
write(A[i, j]:10:3);
end;
writeln;
end;
write('Введите C: ');
readln(C);
ArithMeanColumn(A, C);
readln;
end.