В
Все
Х
Химия
В
Видео-ответы
А
Алгебра
Г
Геометрия
О
ОБЖ
Д
Другие предметы
У
Українська література
Р
Русский язык
Б
Беларуская мова
У
Українська мова
Э
Экономика
Ф
Физика
М
Математика
Ф
Французский язык
Г
География
И
Информатика
М
МХК
О
Окружающий мир
П
Психология
Н
Немецкий язык
О
Обществознание
П
Право
И
История
М
Музыка
Л
Литература
Қ
Қазақ тiлi
Б
Биология
А
Английский язык
HLNLZ
HLNLZ
02.05.2020 15:49 •  Информатика

Надеюсь на вашу ! написать программу на языке 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.

Ответ:
artgensh
artgensh
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
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?