gaifuling4owmrcy
21.02.2021 17:26

Надеюсь на вашу ! написать программу на языке pasсal, меняющую все слова "red" на "black", "tree" на "palms" из текста, указанного в файле in.txt и сохраняющую результат в файл out.txt. все остальные слова, пробелы, запятые, точки и т.п должны остаться без изменений. вот сам текст: a red black tree is a binary search tree where each node has a color attribute the value of which is either red or black in addition to the ordinary requirements imposed on binary search trees the following requirements apply to red black trees. a node is either red or black the root is black this rule is sometimes omitted from other definitions. since the root can always be changed from red to black but not necessarily vice versa this rule has little effect on analysis. all leaves are the same color as the root both children of every red node are black. every simple path from a given node to any of its descendant leaves contains the same number of black, black, black, very "black" nodes.

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
Марина2808
28.06.2020 19:54
Var myInFile, myOutFile: text;
   ind: integer;
   currentString: string;
begin
   assign(myInFile, 'in.txt');
   reset(myInFile);
   assign(myOutFile, 'out.txt');
   rewrite(myOutFile);
   while (not EOF(myInFile)) do
   begin
      currentString := readln(myInFile);
      while (pos('red', currentString) > 0) do
      begin
         ind := pos(currentString, 'red');
         delete(currentString, ind, length('red'));
         insert('black', currentString, ind);
      end;
      while (pos('tree', currentString) > 0) do
      begin
         ind := pos(currentString, 'tree');
         delete(currentString, ind, length('tree'));
         insert('palms', currentString, ind);
      end;
   end;
   close(myInFile);
   close(myOutFile);
end.
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота