klasscho

Untitled

Feb 18th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. procedure LongestWord(var Words: String);
  2. Var
  3. i, j, k, Max: Integer;
  4. Line: String;
  5. begin
  6. i := 1;
  7. Max := 0;
  8. repeat;
  9. j := 0;
  10. While (Words[i] <> ' ') and (i <= length(Words)) do
  11. begin
  12. Inc(i);
  13. Inc(j);
  14. end;
  15. if j > Max then
  16. Max := j;
  17. Inc(i);
  18. until i > length(Words);
  19. Writeln(Max);
  20.  
  21.  
  22. i := 1;
  23. repeat;
  24. j := 0;
  25. while (Words[i] <> ' ') and (i <= length(Words)) Do Begin
  26. Line := Line + Words[i];
  27. Inc(i);
  28. end;
  29. if length(Line) = Max then
  30. Writeln(Line);
  31. Line := '';
  32. Inc(i);
  33. until i > length(Words);
  34. end;
Advertisement
Add Comment
Please, Sign In to add comment