Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program project1;
- const q=5;
- var count,otv,i:integer;
- new,old,a,s:integer;
- List:array [0..q] of integer;
- procedure AddBefore;
- var a,s,k: byte;
- begin
- if count> q then writeln('----List is FULL----');
- if count=0 then
- begin
- writeln('Add new element');
- readln(List[0]);
- count:=count+1;
- exit;
- end;
- if count>0 then
- begin
- writeln('Enter the element before which you want to paste');
- readln(a);
- writeln('Add new element');
- readln(s);
- for k:=0 to 5 do
- if list[k]=a then begin
- for i:=count downto k do
- list[i+1]:=list[i];
- list[k]:=s;
- count:=count+1;
- exit;
- end;
- end;
- end;
- procedure Addafter;
- var a,s,k: byte;
- begin
- if count> q then writeln('----List is FULL----');
- if count=0 then
- begin
- readln(List[0]);
- count:=count+1;
- exit;
- end;
- if count>0 then
- begin
- writeln('Enter the element after which you want to paste');
- readln(a);
- writeln('Add new element');
- readln(s);
- for k:=0 to 5 do
- if List[k]=a then begin
- for i:=count-1 downto k do
- List[i+1]:=List[i];
- List[k+1]:=s;
- count:=count+1;
- end;
- end;
- end;
- procedure Delete;
- var a,s,k: byte;
- i:integer;
- begin
- if count=0 then begin writeln ('List is empty');
- exit;
- end;
- if count>0 then
- begin
- writeln('Enter the element which you want delete:');
- readln(a);
- for k:=0 to 5 do
- if list[k]=a then begin
- for i:=k to count do
- list[i]:=list[i+1];
- exit;
- end;
- end;
- end;
- procedure output;
- begin
- writeln('Content of list:');
- for i:=0 to 5 do
- write (List[i], ' ');
- writeln;
- end;
- begin
- repeat
- write(' Content of list:');
- for i:=0 to 5 do
- write (List[i], ' ');
- writeln;
- writeln('-------MENU--------- ');
- writeln('1-Add the element BEFORE');
- writeln('2-Add the element AFTER');
- writeln('3-Delete the element');
- writeln('4-Output to monitor:');
- writeln('5-Exit:');
- readln(otv);
- case otv of
- 1: begin
- AddBefore;
- end;
- 2: AddAfter;
- 3: Delete;
- 4: output;
- end;
- until otv=5;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement