Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program uniqueWords;
- uses
- SysUtils;
- function areAllLettersUnique(word: string): boolean;
- var
- i: integer;
- begin
- for i := 1 to length(word) - 1 do
- begin
- if word[i] = word[i + 1] then
- begin
- areAllLettersUnique := false;
- exit;
- end;
- end;
- areAllLettersUnique := true;
- end;
- var
- text: string;
- word: string;
- i, wordCount: integer;
- found: boolean;
- begin
- Write('Введите текст: ');
- ReadLn(text);
- found := false;
- wordCount := 0;
- i := 1;
- // Iterate through each character in the text
- while i <= length(text) do
- begin
- // Extract a word from the text
- word := '';
- while (i <= length(text)) and (text[i] <> ' ') do
- begin
- word := word + text[i];
- i := i + 1;
- end;
- wordCount := wordCount + 1;
- WriteLn('..', word, ' ', i,'..');
- // Check if the word has all unique adjacent letters
- if areAllLettersUnique(word) then
- begin
- Write(wordCount, ' ');
- found := true;
- end;
- i := i + 1;
- end;
- WriteLn;
- // If no words with the required condition are found, output a message
- if not found then
- WriteLn('В тексте нет слов, где все соседние буквы различны.');
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement