1)
var a:array[1..20] of integer;
max,min,n,i:integer;
begin
randomize;
n:=20;
for i:=1 to n do a[i]:=random(150);
begin
min:=a[1];
for i:=1 to n do if a[1]>a[i] then min:=a[i];
end;
begin
max:=a[1];
for i:=1 to n do if a[1]<a[i] then max:=a[i];
end;
writeln(min);
writeln(max);
end.
2)
const n=5;
var x: array[1..n,1..n] of integer;
i,j,s: integer;
begin
randomize;
writeln('Matrisa:');
for i:=1 to n do
begin
for j:=1 to n do
begin
x[i,j]:=random(200);
write(x[i,j]:5);
end;
writeln
end;
j:=8;
for i:=1 to n do
begin
j:=j-1;
s:=s+x[i,(n+1-i)];
end;
writeln('Summa: ',s);
end.
1)
var a:array[1..20] of integer;
max,min,n,i:integer;
begin
randomize;
n:=20;
for i:=1 to n do a[i]:=random(150);
begin
min:=a[1];
for i:=1 to n do if a[1]>a[i] then min:=a[i];
end;
begin
max:=a[1];
for i:=1 to n do if a[1]<a[i] then max:=a[i];
end;
writeln(min);
writeln(max);
end.
2)
const n=5;
var x: array[1..n,1..n] of integer;
i,j,s: integer;
begin
randomize;
writeln('Matrisa:');
for i:=1 to n do
begin
for j:=1 to n do
begin
x[i,j]:=random(200);
write(x[i,j]:5);
end;
writeln
end;
j:=8;
for i:=1 to n do
begin
j:=j-1;
s:=s+x[i,(n+1-i)];
end;
writeln('Summa: ',s);
end.
Поделитесь своими знаниями, ответьте на вопрос:
Присвоить 3 элементу массива сумму последних двух элементов
#include <iostream>
using namespace std;
int main()
{
int a[3];
a[3] = a[1] + a[2];
return 0;
}