Advertisement
Semior001

найти все похожие слова

Sep 27th, 2016
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.65 KB | None | 0 0
  1. uses crt;
  2. type
  3.     textOfWords = array[1..26] of string;
  4. var
  5.     w: string;
  6.     result: textOfWords;
  7.     s: string;
  8.     k,n,i,j: integer;
  9.     k_thWord, i_thWord: set of char;
  10.  
  11. procedure toStandart;
  12. begin
  13.  
  14.     // Заменяет все двоеточия в тексте на пробелы
  15.     while pos(':',s)<>0 do
  16.         s[pos(':',s)]:=' ';
  17.  
  18.     // Заменяет все точки с запятой в тексте на пробелы
  19.     while pos(';',s)<>0 do
  20.         s[pos(';',s)]:=' ';
  21.  
  22.     // Заменяет все запятые в тексте на пробелы
  23.     while pos(',',s)<>0 do
  24.         s[pos(',',s)]:=' ';
  25.  
  26.     // Заменяет все точки в тексте на пробелы
  27.     while pos('.',s)<>0 do
  28.         s[pos('.',s)]:=' ';
  29.  
  30.     // Проверка на наличие пробела в конце и если его нет, то добавляет его
  31.     if s[length(s)]<>' ' then
  32.         s:=s+' ';
  33.  
  34.     // Проверка на количество пробелов между словами
  35.     while pos('  ',s)<>0 do
  36.         delete(s,pos('  ',s),1);
  37.  
  38. end;
  39.  
  40. procedure share;
  41. begin
  42.  
  43.     // Разделение строки на массив слов
  44.     while (pos(' ',s)<>0) and (length(s)<>1) do
  45.     begin
  46.         w:=copy(s,1,pos(' ',s));
  47.         delete(w,pos(' ',w),1);
  48.         result[n]:=w;
  49.         n:=n+1;
  50.         delete(s,1,pos(' ',s));
  51.     end;
  52.     n:=n-1;
  53.  
  54. end;
  55.  
  56. begin
  57.     readln(s);
  58.     readln(k);
  59.     n:=1;
  60.    
  61.     toStandart;
  62.     share;
  63.  
  64.     k_thWord:=[];
  65.     for i:=1 to length(result[k]) do
  66.         k_thWord:=k_thWord + [result[k][i]];
  67.  
  68.     for i:=1 to n do
  69.     begin
  70.         i_thWord:=[];
  71.         for j:=1 to length(result[i]) do
  72.             i_thWord:=i_thWord+[result[i][j]];
  73.         if i_thWord=k_thWord then
  74.             writeln(result[i]);
  75.     end;
  76. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement