//Pascal var A: array [1 .. 5, 1 .. 4] of integer; V: array [1 .. 20] of integer; i, j, z: byte; SUM1, SUM2, SUM3, MIN: integer; begin randomize; writeln('***Сгенерированный массив***'); SUM1 := 0; SUM2 := 0; SUM3 := 0; for i := 1 to 5 do begin for j := 1 to 4 do begin A[i, j] := random(30); if ((A[i, j] >= 0) and (A[i, j] <= 5)) then SUM1 := SUM1 + A[i, j]; if ((A[i, j] >= 5) and (A[i, j] <= 15)) then SUM2 := SUM2 + A[i, j]; write(A[i, j]:6) end; writeln; end; writeln('Сумма элементов [0 5] = ', SUM1); writeln('Сумма элементов [5 15] = ', SUM2); MIN := A[3, 1]; for j := 1 to 4 do if A[3, j] < MIN then MIN := A[3, j]; writeln('Минимальный элемент в третьей строке = ', MIN); writeln('***Вектор***'); j := 1; z := 0; while (z < 20) do begin for i := 1 to 5 do begin z := z + 1; V[z] := A[i, j]; end; j := j + 1; end; for i := 1 to 20 do writeln(V[i]:6); for i := 20 downto 10 do SUM3 := SUM3 + V[i]; writeln('Сумма последних 10-ти элементов = ', SUM3); readln; end.
procedure sortbutmeh(var ar:ty;n:integer); Var i,j,c:integer; begin for i:=1 to n-1 do for j:=i+1 to n do if ar[i]<ar[j] then begin c:=ar[i]; ar[i]:=ar[j]; ar[j]:=c; end; end;
begin randomize; readln(n); writeln('First array:'); for i:=1 to n do begin ar[i]:=random(100); write(ar[i]:4); end; sortbutmeh(ar,n); writeln; writeln('Array after sortbutmeh()'); for i:=1 to n do write(ar[i]:4); end.
//2) Var n:integer;
procedure ned(n:integer); begin case n of 1:writeln('Понедельник'); 2:writeln('Вторник'); 3:writeln('Среда'); 4:writeln('Четверг'); 5:writeln('Пятница'); 6:writeln('Суббота'); 7:writeln('Воскресенье'); end; end;
begin readln(n); ned(n); end.
//3) Var s:string;
function lengthbutmeh(s:string):integer; begin while pos(' ',s)<>0 do delete(s,pos(' ',s),1); lengthbutmeh:=length(s); end;
var
A: array [1 .. 5, 1 .. 4] of integer;
V: array [1 .. 20] of integer;
i, j, z: byte;
SUM1, SUM2, SUM3, MIN: integer;
begin
randomize;
writeln('***Сгенерированный массив***');
SUM1 := 0; SUM2 := 0; SUM3 := 0;
for i := 1 to 5 do
begin
for j := 1 to 4 do
begin
A[i, j] := random(30);
if ((A[i, j] >= 0) and (A[i, j] <= 5)) then SUM1 := SUM1 + A[i, j];
if ((A[i, j] >= 5) and (A[i, j] <= 15)) then SUM2 := SUM2 + A[i, j];
write(A[i, j]:6)
end;
writeln;
end;
writeln('Сумма элементов [0 5] = ', SUM1);
writeln('Сумма элементов [5 15] = ', SUM2);
MIN := A[3, 1];
for j := 1 to 4 do if A[3, j] < MIN then MIN := A[3, j];
writeln('Минимальный элемент в третьей строке = ', MIN);
writeln('***Вектор***');
j := 1;
z := 0;
while (z < 20) do
begin
for i := 1 to 5 do
begin
z := z + 1;
V[z] := A[i, j];
end;
j := j + 1;
end;
for i := 1 to 20 do writeln(V[i]:6);
for i := 20 downto 10 do SUM3 := SUM3 + V[i];
writeln('Сумма последних 10-ти элементов = ', SUM3);
readln;
end.
Type
ty=array[1..25] of integer;
Var
n,i:integer;
ar:ty;
procedure sortbutmeh(var ar:ty;n:integer);
Var
i,j,c:integer;
begin
for i:=1 to n-1 do
for j:=i+1 to n do
if ar[i]<ar[j] then
begin
c:=ar[i];
ar[i]:=ar[j];
ar[j]:=c;
end;
end;
begin
randomize;
readln(n);
writeln('First array:');
for i:=1 to n do
begin
ar[i]:=random(100);
write(ar[i]:4);
end;
sortbutmeh(ar,n);
writeln;
writeln('Array after sortbutmeh()');
for i:=1 to n do
write(ar[i]:4);
end.
//2)
Var
n:integer;
procedure ned(n:integer);
begin
case n of
1:writeln('Понедельник');
2:writeln('Вторник');
3:writeln('Среда');
4:writeln('Четверг');
5:writeln('Пятница');
6:writeln('Суббота');
7:writeln('Воскресенье');
end;
end;
begin
readln(n);
ned(n);
end.
//3)
Var
s:string;
function lengthbutmeh(s:string):integer;
begin
while pos(' ',s)<>0 do
delete(s,pos(' ',s),1);
lengthbutmeh:=length(s);
end;
begin
readln(s);
writeln(lengthbutmeh(s));
end.