Program bf5_stack;
LABEL prev,next;
var
a : array[1..10] of integer;
size : integer;
data_arr:array[1..10] of integer; // массив данных
str_arr: string; // команды
i,j,k: integer; // индексы строки и массива
i_stor: integer;
//Stack
procedure push(c : integer);
begin
a[size+1] := c;
size := size + 1;
end;
procedure pop;
begin
size := size - 1;
end;
{---------------------------------------------------}
begin
j:=1; // нумерация элементов массива начинается с единицы
i:=1;
size := 0; {Изначально стек пуст}
//readln(str_arr); //считываем строку
//str_arr:='+++[>+++[>+<-]<-]'; // 3*3=9
str_arr:='+++[> +++[>+++[>+<-]<-] <-]'; // 3^3=27
prev:
if i>length(str_arr) then goto next;
if (str_arr[i]='+') then data_arr[j]:= data_arr[j]+1;
if (str_arr[i]='-') then data_arr[j]:= data_arr[j]-1;
if (str_arr[i]='>') then j:=j+1;
if (str_arr[i]='<') then j:=j-1;
if (str_arr[i]='.') then write(chr(data_arr[j]));
// скобки
if (str_arr[i]='[') then Push(i);
if (str_arr[i]=']') then
begin
Pop();
if (data_arr[j]>0) then
begin
i := a[size+1];
goto prev;
end;
end;
i:=i+1;
goto prev;
next:
for k:=1 to 10 do begin
write(data_arr[k]);
write(' ');
end;
end.
UHJvZ3JhbSBiZjVfc3RhY2s7CiAKIExBQkVMIHByZXYsbmV4dDsKdmFyCiBhIDogYXJyYXlbMS4uMTBdIG9mIGludGVnZXI7CiBzaXplIDogaW50ZWdlcjsKIGRhdGFfYXJyOmFycmF5WzEuLjEwXSBvZiBpbnRlZ2VyOyAgICAvLyDQvNCw0YHRgdC40LIg0LTQsNC90L3Ri9GFCiBzdHJfYXJyOiBzdHJpbmc7ICAgICAgICAgICAgICAgICAgICAgLy8g0LrQvtC80LDQvdC00YsgIAogaSxqLGs6IGludGVnZXI7ICAgICAgICAgICAgICAgICAgICAgIC8vINC40L3QtNC10LrRgdGLINGB0YLRgNC+0LrQuCDQuCDQvNCw0YHRgdC40LLQsAogaV9zdG9yOiBpbnRlZ2VyOyAKCi8vU3RhY2sKcHJvY2VkdXJl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