program q1;
uses crt;
const n=10;
type stack=array[1..n div 2] of integer;
var
tos,i,max:integer;
a:array[1..n] of integer;
s1,s2:stack;
procedure push(s:stack;e:integer);
begin
if tos>=max then writeln('your brein is full')
else
begin
s[tos]:=e;
tos:=tos+1;
end;
end;
begin
max:=n; tos:=1;
clrscr;
writeln('elementu masuvy');
for i:=1 to n do
begin
a[i]:=random(30);
writeln('a[',i,']= ',a[i]);
end;
writeln;
writeln;
writeln('elementu 1shogo steky');
for i:=1 to n div 2 do
begin
push(s1,a[i]);
writeln('s1[',i,']= ',s1[i]);
end;
writeln;
writeln;
tos:=6;
writeln('elementu 2gogo steky');
for i:=n downto n div 2 +1 do
begin
push(s2,a[i]);
writeln('s2[',i,']= ',s2[i]);
end;
readkey;
end.
Почему ТП вырубается |