Найти мин и макс строки и поменять их местами- Pascal(Паскаль)

Program stroki;
uses crt;
const n=5;
var st:array[1..n] of string[50]; strr:string[50];
k1,k2,i,j,imin,imax:integer;
begin
clrscr;
for j:=1 to n do
begin
writeln('BBedute 20 3hakoB');
readln(st[j]);
k1:=0;
k2:=0;
for i:=1 to length(st[j]) do
begin
if st[j,i] = 'v'then
k1:=k1+1;
if (st[j,i]= 'o')  and  (st[j,i+1]= 't') then
k2:=k2+1;
end;
writeln ('V stroke ''v'' vstrechaetsya ',k1, ' raz, ''ot''- ',k2);
end;
 
writeln;
for i:=1 to n do
writeln(st[i]);
 
strr:=st[1];
imin:=1;
for i:=2 to n do
if (length(st[i])) < (length(strr)) then begin imin:=i; strr:=st[i] end;
writeln('Stroka ',imin,' minimalna');
 
strr:=st[1];
imax:=1;
for i:=2 to n do
if length(st[i]) > length(strr) then begin imax:=i; strr:=st[i] end;
writeln('Stroka ',imax,' maximalna');
 
strr:=st[imin];
st[imin]:=st[imax];
st[imax]:=strr;
writeln;
 
for i:=1 to n do
writeln(st[i]);
end.

Leave a Comment

3 + 4 =