Guest User

Untitled

a guest
Dec 10th, 2019
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program Project1;
  2. {$APPTYPE CONSOLE}
  3. {$R *.res}
  4.  
  5. uses
  6. System.SysUtils;
  7.  
  8. type
  9. TArrOfStr = array [1 .. 128] of string;
  10.  
  11. var
  12. MainStr: string;
  13. LastWord: string;
  14. BaseOfWords: TArrOfStr;
  15. NumberOfWords: integer;
  16.  
  17. function ReturnLastWord(Str: string): string;
  18. var
  19. counter, LenStr: integer;
  20. begin
  21. LenStr := Length(Str);
  22. counter := Length(Str);
  23. while (Str[counter] <> ' ') and (counter > 0) do
  24. dec(counter);
  25. inc(counter);
  26. result := Copy(Str, counter, LenStr - counter + 1);
  27. end;
  28.  
  29. function DeleteWords(Str, Word: string): string;
  30. var
  31. counter, LenOfWord, index: integer;
  32. begin
  33.  
  34. LenOfWord := Length(Word);
  35. while Pos(Word, Str) > 0 do
  36. begin
  37.  
  38. index := Pos(Word, Str);
  39.  
  40. Delete(Str, index, LenOfWord + 1);
  41.  
  42. end;
  43.  
  44. result := Str;
  45. end;
  46.  
  47. procedure CountNumberOfVowels(Str: string);
  48. var
  49. counter, LenOfStr: integer;
  50. Vowels: array [1 .. 6] of integer;
  51. begin
  52. for counter := 1 to 6 do
  53. Vowels[counter] := 0;
  54.  
  55. LenOfStr := Length(Str);
  56. for counter := 1 to LenOfStr do
  57. begin
  58. case Str[counter] of
  59. 'a':
  60. inc(Vowels[1]);
  61. 'e':
  62. inc(Vowels[2]);
  63. 'i':
  64. inc(Vowels[3]);
  65. 'o':
  66. inc(Vowels[4]);
  67. 'u':
  68. inc(Vowels[5]);
  69. 'y':
  70. inc(Vowels[6]);
  71. end;
  72.  
  73. end;
  74. // Output
  75.  
  76. writeln('a:',Vowels[1]);
  77. writeln('e:',Vowels[2]);
  78. writeln('i:',Vowels[3]);
  79. writeln('o:',Vowels[4]);
  80. writeln('u:',Vowels[5]);
  81. writeln('y:',Vowels[6]);
  82.  
  83. end;
  84.  
  85. function GetArrayOfString(Str: string; var BaseOfWords: TArrOfStr): integer;
  86. var
  87. LenStr: integer;
  88. counter, NumberOfWords, IndexBeginOfTheWord: integer;
  89. begin
  90.  
  91. Trim(Str);
  92. NumberOfWords := 1;
  93. LenStr := Length(Str);
  94. IndexBeginOfTheWord := 1;
  95.  
  96. for counter := 1 to LenStr do
  97. begin
  98.  
  99. if Str[counter] = ' ' then
  100. begin
  101.  
  102. BaseOfWords[NumberOfWords] := BaseOfWords[NumberOfWords] +
  103. Copy(Str, IndexBeginOfTheWord, counter - IndexBeginOfTheWord);
  104. IndexBeginOfTheWord := counter + 1;
  105. inc(NumberOfWords);
  106.  
  107. end;
  108.  
  109. end;
  110. result := NumberOfWords - 1;
  111. // hello_my_name_is
  112. { writeln('Output of the words:');
  113. for counter := 1 to 10 do
  114. writeln('|', BaseOfWords[counter], '|'); }
  115.  
  116. end;
  117.  
  118. procedure WriteWords(Base: TArrOfStr; NumberOfWords: integer);
  119. var
  120. counter: integer;
  121. i, j, k: integer;
  122. cashWord: string;
  123. LastSymbol, FirstSymbol: char;
  124. begin
  125. LastSymbol := Base[1][Length(Base[1])];
  126. write(Base[1]);
  127. Base[1] := '_';
  128.  
  129. for j := 1 to NumberOfWords do
  130. for i := 1 to NumberOfWords do
  131. begin
  132.  
  133. if Base[i][1] = LastSymbol then
  134. begin
  135.  
  136. write(' ', Base[i]);
  137. LastSymbol := Base[i][Length(Base[i])];
  138.  
  139. Base[i] := '_';
  140.  
  141. end;
  142.  
  143. end;
  144.  
  145. end;
  146.  
  147. begin
  148. try
  149. readln(MainStr);
  150. //Str := 'hg jf kr ld sh fu et kh uf nd gk as de if ';
  151. MainStr := Trim(MainStr);
  152. LastWord := ReturnLastWord(MainStr);
  153. MainStr := DeleteWords(MainStr, LastWord);
  154. writeln(MainStr);
  155. CountNumberOfVowels(MainStr);
  156. NumberOfWords := GetArrayOfString(MainStr, BaseOfWords);
  157.  
  158. WriteWords(BaseOfWords, NumberOfWords);
  159.  
  160. readln;
  161.  
  162. except
  163. begin
  164.  
  165. writeln('Строка пустая');
  166.  
  167. end
  168. end;
  169. readln;
  170. end.
RAW Paste Data