Advertisement
r4lovets

Untitled

Jun 12th, 2019
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.59 KB | None | 0 0
  1. program Task2;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. {$R *.res}
  6.  
  7. uses
  8.   System.SysUtils;
  9.  
  10. const
  11.   VOWELS = ['а', 'о', 'у', 'ы', 'э', 'я', 'ю', 'и', 'е'];
  12.  
  13. type
  14.   TSet = Set of Char;
  15.  
  16. var
  17.   res: TSet;
  18.   str: AnsiString;
  19.   i: Integer;
  20.  
  21. function GetOtherVowels(str: AnsiString; i: Integer): TSet;
  22.  
  23. var
  24.   j: Integer;
  25.   res: TSet;
  26.  
  27. begin
  28.   res := [];
  29.   for j := i to Length(str) do
  30.     if str[j] in VOWELS then
  31.       res := res + [str[j]];
  32.   GetOtherVowels := res;
  33. end;
  34.                   // строка       // начало строки
  35. function GetWord(str: AnsiString; i: Integer): AnsiString;
  36.  
  37. var
  38.   res: AnsiString;
  39.  
  40. begin
  41.   res := '';
  42.   while (str[i] <> ',') and (str[i] <> '.') do
  43.     begin
  44.       res := res + str[i];
  45.       Inc(i);
  46.     end;
  47.   GetWord := res;
  48. end;
  49.  
  50. function GetVowelsFromWord(word: AnsiString): TSet;
  51.  
  52. var
  53.   i: Integer;
  54.   res: TSet;
  55.  
  56. begin
  57.   res := [];
  58.   for i := 1 to Length(word) do
  59.     if word[i] in VOWELS then
  60.       res := res + [word[i]];
  61.   GetVowelsFromWord := res;
  62. end;
  63.  
  64. procedure GetResultSet(var resSet: TSet; str: AnsiString);
  65.  
  66. var
  67.   i: Integer;
  68.   word: AnsiString;
  69.  
  70. begin
  71.   resSet := [];
  72.   i := 0;
  73.  
  74.   repeat
  75.     Inc(i);
  76.     word := GetWord(str, i);
  77.     resSet := resSet + (GetVowelsFromWord(word) * GetOtherVowels(str, i + Length(word)));
  78.     Inc(i, Length(word));
  79.   until str[i] = '.';
  80. end;
  81.  
  82. procedure PrintSet(x: TSet);
  83.  
  84. var
  85.   i: AnsiChar;
  86.  
  87. begin
  88.   for i := 'а' to 'я' do
  89.     if i in x then
  90.       Write(i, ' ');
  91. end;
  92.  
  93. begin
  94.   Readln(str);
  95.  
  96.   GetResultSet(res, str);
  97.   PrintSet(res);
  98.  
  99.   Readln;
  100. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement