Advertisement
green1ant

Untitled

Dec 7th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. var
  2. S, Word: string;
  3. i, j, LastIndex, WordLen: Integer;
  4. ShouldWrite: Boolean;
  5. begin
  6. Writeln('Enter string:');
  7. Readln(S);
  8.  
  9. i := 1;
  10. LastIndex := Length(S);
  11.  
  12. while S[LastIndex] <> ' ' do
  13. Dec(LastIndex);
  14.  
  15. Writeln('Result: ');
  16. while i <= LastIndex do
  17. begin
  18. WordLen := 0;
  19. j := i;
  20. ShouldWrite := True;
  21. Word := '';
  22. while S[j] <> ' ' do
  23. begin
  24. if Pos(S[j], Word) <> 0 then
  25. ShouldWrite := False;
  26. Word := Word + S[j];
  27. Inc(j);
  28. Inc(WordLen);
  29. end;
  30. if ShouldWrite then
  31. Write(Word, ' ');
  32. Inc(i, WordLen + 1);
  33. end;
  34.  
  35. Readln;
  36. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement