Íàõîæäåíèå ñàìîãî äëèííîãî ñëîâà â òåêñòîâîì ôàéëå.

 

Uses CRT;

 

Var MaxL,Temp,S : String;

    F : Text;

 

Function MaxLength(C:String):String;

Var Pb : Byte;

    Result : String;

Begin

     Result := '';

     While Pos(' ',C) <> 0 Do Begin

       Pb := Pos(' ',C);

       If Length(Result) < Length(Copy(C,1,Pb-1)) Then Result := Copy(C,1,Pb-1);

       Delete(C,1,Pb);

     End;

     If Result < C Then Result := C;

     MaxLength := Result;

End;

 

Begin

     ClrScr;

     Temp := '';

     If ParamCount >= 1 Then Begin

        Assign(F,ParamStr(1));

        Reset(F);

        While NOT(EOF(F)) Do Begin

            ReadLn(F,S);

            MaxL := MaxLength(S);

            If Length(Temp) < Length(MaxL) Then Temp := MaxL;

            GoToXY(1,1); WriteLn(Temp);

        End;

        Close(F);

        WriteLn;

        WriteLn('Ñàìàÿ áîëüøàÿ ïîñëåäîâàòåëüíîñòü ñèìâîëîâ â ôàéëå ',ParamStr(1),' - ',Temp);

     End Else WriteLn('Ïðîïóùåíî èìÿ ôàéëà');

Readkey;

End.