Цитата:
Сообщение от Сова
Очень нужна помощь...
|
Легко.
Имена файлов и пути, если надо, поправьте.
Код:
Var
f,f1:Text;
N_lines,N_words,N_symbols,i,j,k,Jmin,Jmax,Min:Byte;
N_5:Array[1..30] of Byte;
Ch:Char;
S:String;
Begin
Assign(f,'D:\XXX.txt');
Rewrite(f);
Assign(f1,'D:\YYY.txt');
Rewrite(f1);
Randomize;
N_lines:=20+Random(11);
For i:=1 to N_lines do
begin
N_words:=Random(20)+1;
For j:=1 to N_words do
begin
N_symbols:=Random(8)+1;
For k:=1 to N_symbols do
write(f,Chr(97+Random(26)));
If j<N_words then write(f,' ');
end;
writeln(f);
end;
Close(f);
Reset(f);
i:=0;
Repeat
Inc(i);
N_5[i]:=0;
j:=0;
Repeat
Inc(j);
read(f,Ch);
If j=1 then Jmin:=1;
Repeat
Inc(j);
read(f,Ch);
Until (Ch=' ') or EoLn(f);
If Ch=' ' then Jmax:=j else Jmax:=j+1;
If Jmax-Jmin=5 then Inc(N_5[i]);
If Ch=' ' then Jmin:=j+1;
Until EoLn(f);
If Not(EoF(f)) then readln(f);
Until EoF(f);
Close(f);
N_lines:=i;
Min:=21;
For i:=1 to N_lines do
If N_5[i]<Min then Min:=N_5[i];
Reset(f);
For i:=1 to N_Lines do
begin
readln(f,S);
If N_5[i]>Min then writeln(f1,S);
end;
Close(f);
Close(f1);
End.