const
MAX = 20;
var
s:string;
stack:array[1..MAX] of string;
top:integer;
i:byte;
procedure Push(ch:string);
begin
if top>=MAX then WriteLn('Stask full')
else
begin
stack[top]:=ch;
top:=top+1;
end;
end;
function Pop:string;
begin
top:=top-1;
if top<1 then
begin
WriteLn('Stack underflow');
top:=top+1;
end
else Pop := stack[top];
end;
begin
top:=1;
s:='<asdf<asdf>asdf>';//правильная строка
for i:=1 to length(s) do
begin
if s[i]='<' then Push('<');
if s[i]='>' then
if Pop()<>'<' then WriteLn('Ошибка!');
end;
if top<>1 then WriteLn('Ошибка!');
top:=1;
s:='<asdf<asdfasdf>';//не правильная строка
for i:=1 to length(s) do
begin
if s[i]='<' then Push('<');
if s[i]='>' then
if Pop()<>'<' then WriteLn('Ошибка!');
end;
if top<>1 then WriteLn('Ошибка!');
end.
Объяснение:
Поделитесь своими знаниями, ответьте на вопрос:
Определи значение переменной a после выполнения фрагмента алгоритма при a=2 и a=14. Ввод а если a>5 то a:=a+20 иначе a:=a*10 всё при a=2 значение переменной a равно при a=14 значение переменной a равно
при а =2. будет 20
при а=14. будет 34