Найти произведение элементов двумерного массива, размером 3 на 3. Значения элеме тонтов массива вводятся с клавиатуры. Резльтат выводится на экран заранее
191
389
Ответы на вопрос:
//pascalabc.net 3.1 сборка 1239 var brackets: array [0..2, 0..1] of char : = (('{', '}'), ('[', ']'), ('(', ')')); begin var s : = readlnstring(); var counter : = 0; var max_depth : = 0; for var i : = 1 to s.length do begin if s[i] = '(' then counter += 1 else if s[i] = ')' then counter -= 1 else continue; if counter < 0 then begin writeln('brackets error'); halt; end; if counter > max_depth then max_depth : = counter; end; counter : = 0; for var i : = 1 to s.length do begin if s[i] = '(' then counter += 1 else if s[i] = ')' then counter -= 1 else continue; if (counter = max_depth - 1) and (s[i] = '(') then s[i] : = brackets[1, 0] else if (counter = max_depth - 2) and (s[i] = ')') then s[i] : = brackets[1, 1] else if (counter = max_depth - 2) and (s[i] = '(') then s[i] : = brackets[0, 0] else if (counter = max_depth - 3) and (s[i] = ')') then s[i] : = brackets[0, 1]; end; writeln(s); end.
Популярно: Информатика
-
danil20080408.02.2020 09:38
-
Футболист11111108.09.2021 03:23
-
Meowmeowmi02.04.2020 17:50
-
nikitkaapalkov28.03.2020 19:31
-
влада41515.12.2021 05:45
-
BizzyGames30.10.2021 20:01
-
Машунчик22519.05.2021 16:48
-
Xadice1234525.01.2020 09:14
-
krasovskyko20117.07.2022 22:17
-
ТаНюша245121.06.2021 23:55