Guest User

Untitled

a guest
Dec 6th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.95 KB | None | 0 0
  1. program Project8;
  2.  
  3. {$APPTYPE CONSOLE}
  4. {$R *.res}
  5.  
  6. uses
  7.   System.SysUtils;
  8.  
  9. function FindingFile(): String;
  10. var
  11.   CorrectFile: Boolean;
  12.   NameOfFile, Str: String;
  13.   Input: TextFile;
  14. begin
  15.   repeat
  16.     Write('Введите путь к файлу, с которого хотите считать информацию :');
  17.     Readln(NameOfFile);
  18.     CorrectFile := True;
  19.     try
  20.       AssignFile(Input, NameOfFile);
  21.       Reset(Input);
  22.       if not eof(Input) then
  23.       begin
  24.         Read(Input, Str);
  25.         CloseFile(Input);
  26.       end
  27.       else
  28.       begin
  29.         WriteLn(' Файл оказался пустым ');
  30.         CloseFile(Input);
  31.       end;
  32.     except
  33.       CorrectFile := False;
  34.       WriteLn('Не удалось найти файл по такому пути', NameOfFile);
  35.     end;
  36.   until CorrectFile;
  37.   FindingFile := Str;
  38. end;
  39.  
  40. function CharacterInsertion(Str: String): String;
  41. var
  42.   i: integer;
  43. begin
  44.   for i := Str.Length downto 0 do
  45.   begin
  46.     if (Str[i] in ['a', 'u', 'e', 'o', 'y', 'i']) then
  47.       begin
  48.         Insert('*', Str, i + 1);
  49.       end;
  50.   end;
  51.   CharacterInsertion := Str ;
  52. end;
  53.  
  54. procedure SaveFile(NameOutput: String; Str : String);
  55. var
  56.   Output: TextFile;
  57. begin
  58.   WriteLn('Введите путь к файлу для записи : ');
  59.   Readln(NameOutput);
  60.   AssignFile(Output, NameOutput);
  61.   Rewrite(Output);
  62.   WriteLn(Output, ' Новая строка : ', Str);
  63.   CloseFile(Output);
  64.   Readln;
  65. end;
  66.  
  67. var
  68.   k: integer;
  69.   NameOutput: String;
  70.   Str : String;
  71. begin
  72.   Write('Дана строка символов , состоящая из произвольного текста на английском языке , слова разделены пробелом.');
  73.   WriteLn('После каждого гласного символа вставить символ " * " ');
  74.   Str := FindingFile();
  75.   Str := CharacterInsertion(Str);
  76.   SaveFile(NameOutput, Str);
  77.   Readln;
  78. end.
Advertisement
Add Comment
Please, Sign In to add comment