Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure LongestWord(var Words: String);
- Var
- i, j, k, Max: Integer;
- Line: String;
- begin
- i := 1;
- Max := 0;
- repeat;
- j := 0;
- While (Words[i] <> ' ') and (i <= length(Words)) do
- begin
- Inc(i);
- Inc(j);
- end;
- if j > Max then
- Max := j;
- Inc(i);
- until i > length(Words);
- Writeln(Max);
- i := 1;
- repeat;
- j := 0;
- while (Words[i] <> ' ') and (i <= length(Words)) Do Begin
- Line := Line + Words[i];
- Inc(i);
- end;
- if length(Line) = Max then
- Writeln(Line);
- Line := '';
- Inc(i);
- until i > length(Words);
- end;
Advertisement
Add Comment
Please, Sign In to add comment