Программа:
Pascal:
№1)
var arr: array[1..10] of integer;
begin
for var i := 1 to 10 do arr[i] := random(100);
writeln(arr);
end.
№2)
const N = 15;
var arr: array[1..N] of integer;
i, tmp: integer;
for i := 1 to 15 do arr[i] := random(100);
for i:=1 to n div 2 do begin
tmp := arr[i];
arr[i] := arr[N - i + 1];
arr[N - i + 1]:= tmp;
end;
№3)
const N = 20;
var
arr: array[1..N] of integer;
i, tmp, j: integer;
for i := 1 to N do readln(arr[i]);
for i := 1 to N - 1 do
for j := 1 to N - i do
if (arr[j] > arr[j+1]) then begin
tmp := arr[j];
arr[j] := arr[j+1];
arr[j+1] := tmp;
#include <iostream>
using namespace std;
int main()
{
int n, m;
int **arr;
int min;
cout << "Enter dimension of array (n/m)" << endl;
cin >> n >> m;
arr = new int *[n];
for (int i = 0; i < n; i++) {
arr[i] = new int[m];
}
for (int j = 0; j < m; j++) {
cout << "arr[" << i << "][" << j << "] = ";
cin >> arr[i][j];
cout << "Your array:" << endl;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
cout << arr[i][j] << " ";
cout << endl;
cout << "Min is: ";
min = arr[0][0];
if (min > arr[i][j]) {
min = arr[i][j];
cout << min << endl;
return 0;
Программа:
Pascal:
№1)
var arr: array[1..10] of integer;
begin
for var i := 1 to 10 do arr[i] := random(100);
writeln(arr);
end.
№2)
const N = 15;
var arr: array[1..N] of integer;
i, tmp: integer;
begin
for i := 1 to 15 do arr[i] := random(100);
writeln(arr);
for i:=1 to n div 2 do begin
tmp := arr[i];
arr[i] := arr[N - i + 1];
arr[N - i + 1]:= tmp;
end;
writeln(arr);
end.
№3)
const N = 20;
var
arr: array[1..N] of integer;
i, tmp, j: integer;
begin
for i := 1 to N do readln(arr[i]);
writeln(arr);
for i := 1 to N - 1 do
for j := 1 to N - i do
if (arr[j] > arr[j+1]) then begin
tmp := arr[j];
arr[j] := arr[j+1];
arr[j+1] := tmp;
end;
writeln(arr);
end.
#include <iostream>
using namespace std;
int main()
{
int n, m;
int **arr;
int min;
cout << "Enter dimension of array (n/m)" << endl;
cin >> n >> m;
arr = new int *[n];
for (int i = 0; i < n; i++) {
arr[i] = new int[m];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << "arr[" << i << "][" << j << "] = ";
cin >> arr[i][j];
}
}
cout << "Your array:" << endl;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cout << arr[i][j] << " ";
}
cout << endl;
}
cout << "Min is: ";
min = arr[0][0];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (min > arr[i][j]) {
min = arr[i][j];
}
}
}
cout << min << endl;
return 0;
}