begin var n := ReadlnInteger('n = '); var m := ReadlnInteger('m = '); var rand := ReadlnInteger('Для ручного ввода нажмите 0');
if rand = 0 then begin a := new integer[m, n]; for var i := 0 to m-1 do for var j := 0 to n-1 do a[i, j] := ReadlnInteger('a[' + i + ',' + j + '] = '); end else a := MatrixRandom(m, n, 1, 100); Println(a);
var b := ArrGen(n, x -> 1); for var i := 0 to m-1 do for var j := 0 to n-1 do if j mod 2 = 0 then b[j] := b[j] * a[i, j];
b.Where((x, i)-> i mod 2 = 0).SortedDescending().Println(); end.
#include <iostream> #include <cstdlib> #include <ctime> int main() { using namespace std; cout << "Enter size of array: "; int N; cin >> N; int * ARR = new int[N]; srand(time(0)); int i; for (i = 0; i < N; ++i) ARR[i] = rand() % 100 + 1;
cout << "Here is an original array:\n"; for (i = 0; i < N; ++i) cout << ARR[i] << " "; cout << endl;
int temp = ARR[N - 1]; for (i = N - 1; i > 0; --i) ARR[i] = ARR[i - 1]; ARR[0] = temp;
cout << "\nHere is a new array:\n"; for (i = 0; i < N; ++i) cout << ARR[i] << " "; cout << endl;
a: array [,] of integer;
begin
var n := ReadlnInteger('n = ');
var m := ReadlnInteger('m = ');
var rand := ReadlnInteger('Для ручного ввода нажмите 0');
if rand = 0 then begin
a := new integer[m, n];
for var i := 0 to m-1 do
for var j := 0 to n-1 do
a[i, j] := ReadlnInteger('a[' + i + ',' + j + '] = ');
end
else a := MatrixRandom(m, n, 1, 100);
Println(a);
var b := ArrGen(n, x -> 1);
for var i := 0 to m-1 do
for var j := 0 to n-1 do
if j mod 2 = 0 then
b[j] := b[j] * a[i, j];
b.Where((x, i)-> i mod 2 = 0).SortedDescending().Println();
end.
#include <cstdlib>
#include <ctime>
int main()
{
using namespace std;
cout << "Enter size of array: ";
int N;
cin >> N;
int * ARR = new int[N];
srand(time(0));
int i;
for (i = 0; i < N; ++i)
ARR[i] = rand() % 100 + 1;
cout << "Here is an original array:\n";
for (i = 0; i < N; ++i)
cout << ARR[i] << " ";
cout << endl;
int temp = ARR[N - 1];
for (i = N - 1; i > 0; --i)
ARR[i] = ARR[i - 1];
ARR[0] = temp;
cout << "\nHere is a new array:\n";
for (i = 0; i < N; ++i)
cout << ARR[i] << " ";
cout << endl;
return 0;
}