Const n=20; var a,b:array[1..n] of integer; i,j,k,m,c:integer; begin Randomize; writeln('Исходный массив:'); for i:=1 to n do begin a[i]:=random(51)-25; write(a[i]:5); end; writeln; j:=0; for i:=1 to n do if a[i]<0 then begin j:=j+1; b[j]:=a[i]; end; m:=j; for k := 1 to m-1 do for i := 1 to m-k do if (b[i]<b[i+1]) then begin c:=b[i]; b[i]:=b[i+1]; b[i+1]:=c; end; writeln('Вс массив:'); for i:=1 to m do write(b[i]:5); writeln; j:=0; for i:=1 to n do if a[i]<0 then begin j:=j+1; a[i]:=b[j]; end; writeln('Полученный массив:'); for i:=1 to n do write(a[i]:5); writeln; end.
var
s: string;
i, count: integer;
begin
writeln('Vvedite stroky: ');
readln(s);
for i := 1 to length(s) - 2 do
if copy(s, i, 3) = 'abc' then
count := count + 1;
writeln('Kol-vo: ', count);
end.
2.
var
s1, s2: string;
i, len1, len2: integer;
begin
writeln('Vvedite stroky 1: ');
readln(s1);
writeln('Vvedite stroky 2: ');
readln(s2);
len1 := length(s1);
len2 := length(s2);
if len1 > len2 then writeln('1 stroka dlinnee')
else if len1 < len2 then writeln('2 stroka dlinnee')
else writeln('dlini strok ravnie')
end.
3.
var
s1, s2, s3: string;
begin
writeln('Vvedite stroky 1: ');
readln(s1);
writeln('Vvedite stroky 2: ');
readln(s2);
s3 := s1[1] + s1[2] + s2[1] + s2[2];
writeln('Novaja stroka: ', s3);
end.
var
a,b:array[1..n] of integer;
i,j,k,m,c:integer;
begin
Randomize;
writeln('Исходный массив:');
for i:=1 to n do
begin
a[i]:=random(51)-25;
write(a[i]:5);
end;
writeln;
j:=0;
for i:=1 to n do
if a[i]<0 then begin j:=j+1; b[j]:=a[i]; end;
m:=j;
for k := 1 to m-1 do
for i := 1 to m-k do
if (b[i]<b[i+1]) then
begin
c:=b[i]; b[i]:=b[i+1]; b[i+1]:=c;
end;
writeln('Вс массив:');
for i:=1 to m do write(b[i]:5);
writeln;
j:=0;
for i:=1 to n do
if a[i]<0 then begin j:=j+1; a[i]:=b[j]; end;
writeln('Полученный массив:');
for i:=1 to n do write(a[i]:5);
writeln;
end.
Пример:
Исходный массив:
-15 -8 -6 -13 15 24 5 -2 14 -1 19 -2 -7 -8 -23 20 -2 7 -2 -10
Вс массив:
-1 -2 -2 -2 -2 -6 -7 -8 -8 -10 -13 -15 -23
Полученный массив:
-1 -2 -2 -2 15 24 5 -2 14 -6 19 -7 -8 -8 -10 20 -13 7 -15 -23