SlideShare a Scribd company logo
1 of 16
STACK (TUMPUKAN)

 Pengertian Stack
  Stack adalah kumpulan data yang dapat
 diletakkan data lain di atasnya.
  Perlu diingat bahwa kita hanya bisa
 menambah dan menghapus elemennya dari
 ujung atas saja. Proses seperti ini disebut juga
 Last In First Out ( LIFO ). .
Operasi Pada Stack
 Inisialisasi
    Yaitu membuat stack dalam keadaan kosong.
   Push
    Yaitu Proses memasukkan elemen baru pada stack
   Pop
    Yaitu mengambil elemen dari stack.
   Size
    Yaitu operasi menetahui jumlah elemen stack.
   Empty
    Yaitu untuk mengetahui stack kosong atau tidak.
   Full
    Yaitu mengetahui status stack
Uses crt;
         Listning Program STACK
const
   max = 10;
var
top,i        : byte;
pil,tem,E : char;
stack         : array [1..max] of char;
procedure pushanim;
   begin
      for i :=1 to 18 do
        begin
            gotoxy(23+i,7); write(tem);
            {Delay(30);}
            gotoxy(23,7); clreol;
        end;
      for i:=1 to 14-top do
        begin
            {delay(30);}
            gotoxy(41,6+i); write(' ');
            gotoxy(41,7+i); write(tem);
        end;
   end;
procedure popanim(tem:char);
  begin
     for i:=1 to 14-top do
       begin
           {delay(30);}
           gotoxy(41,22-i-top); write(' ');
           gotoxy(41,21-i-top); write(tem);
       end;
     for i:=1 to 19 do
       begin
           gotoxy(40+i,7); write(tem);
{delay(30);}
           gotoxy(16,7); clreol;
       end;
   end;

procedure push(e:char);
 begin
   inc(top);
   stack[top] :=e;
   pushanim;
 end;
procedure pop(e:char);
  begin
     if top<> 0 then
       begin
          E:=stack[top];popanim(e);
          dec(top);
       end else
       begin
          gotoxy(1,7); write('stack telah kosong');
readkey;
          gotoxy(1,7); clreol;
         end;
    end;
begin
   clrscr;
   writeln('ANIMASI STACK');
   writeln('1. PUSH (MASUKKAN DATA)');
   writeln('2. POP (MENGHAPUS)‘);
   writeln('3. QUIT (KELUAR)');
   writeln('Pilihan anda[1/2/3] = ');
   gotoxy(49,6);write('');
   gotoxy(49,8);write('/');
   gotoxy(37,10);write(' /');
   for i:=1 to 11 do
begin
gotoxy(38,10+i);
     if i=11 then write('|_____|')else write
     ('| |');
  end;
top := 0;
repeat
   gotoxy(23,5);clreol;
   pil := readkey;write(pil);
   if pil ='1' then
     begin
         if top<> max then
           begin
              gotoxy(1,7);write('Masukkan satu Huruf = ');
              tem := readkey;write(tem);
              push(tem);
              gotoxy(1,7);clreol;
           end else
              begin
                gotoxy(1,7);write('Stack sudah penuh');readkey;
                gotoxy(1,7);clreol;
              end;
     end else
   if pil='2' then pop(tem);
until pil='3';
end.
Listing Program
Hasil Program Stack
OUTPUT
Kelompok 4

More Related Content

What's hot

Program to implement searching in a text file
Program to implement searching in a text fileProgram to implement searching in a text file
Program to implement searching in a text fileHarryPotter745997
 
C Language - Switch and For Loop
C Language - Switch and For LoopC Language - Switch and For Loop
C Language - Switch and For LoopSukrit Gupta
 
Simulador carrera de caballos desarrollado en C++
Simulador carrera de caballos desarrollado en C++Simulador carrera de caballos desarrollado en C++
Simulador carrera de caballos desarrollado en C++Santiago Sarmiento
 
Os scheduling Algorithms
Os scheduling AlgorithmsOs scheduling Algorithms
Os scheduling AlgorithmsNeelamani Samal
 
Double linked list
Double linked listDouble linked list
Double linked listraviahuja11
 
The Ring programming language version 1.5.3 book - Part 20 of 184
The Ring programming language version 1.5.3 book - Part 20 of 184The Ring programming language version 1.5.3 book - Part 20 of 184
The Ring programming language version 1.5.3 book - Part 20 of 184Mahmoud Samir Fayed
 
バイオインフォ分野におけるtidyなデータ解析の最新動向
バイオインフォ分野におけるtidyなデータ解析の最新動向バイオインフォ分野におけるtidyなデータ解析の最新動向
バイオインフォ分野におけるtidyなデータ解析の最新動向弘毅 露崎
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซีkramsri
 
Ptyhon 教學 002 程式流程控制(while-for)
Ptyhon 教學 002 程式流程控制(while-for)Ptyhon 教學 002 程式流程控制(while-for)
Ptyhon 教學 002 程式流程控制(while-for)信宏 陳
 
The Ring programming language version 1.3 book - Part 12 of 88
The Ring programming language version 1.3 book - Part 12 of 88The Ring programming language version 1.3 book - Part 12 of 88
The Ring programming language version 1.3 book - Part 12 of 88Mahmoud Samir Fayed
 
Linux Command Line Multitasking
Linux Command Line MultitaskingLinux Command Line Multitasking
Linux Command Line MultitaskingAmr Fawzy
 

What's hot (20)

Program to implement searching in a text file
Program to implement searching in a text fileProgram to implement searching in a text file
Program to implement searching in a text file
 
C Language - Switch and For Loop
C Language - Switch and For LoopC Language - Switch and For Loop
C Language - Switch and For Loop
 
Scripting ppt
Scripting pptScripting ppt
Scripting ppt
 
Simulador carrera de caballos desarrollado en C++
Simulador carrera de caballos desarrollado en C++Simulador carrera de caballos desarrollado en C++
Simulador carrera de caballos desarrollado en C++
 
FSE 2008
FSE 2008FSE 2008
FSE 2008
 
Looping in C
Looping in CLooping in C
Looping in C
 
MFC Menu
MFC MenuMFC Menu
MFC Menu
 
For Loop
For LoopFor Loop
For Loop
 
Os scheduling Algorithms
Os scheduling AlgorithmsOs scheduling Algorithms
Os scheduling Algorithms
 
Job09
Job09Job09
Job09
 
Double linked list
Double linked listDouble linked list
Double linked list
 
Sol9
Sol9Sol9
Sol9
 
The Ring programming language version 1.5.3 book - Part 20 of 184
The Ring programming language version 1.5.3 book - Part 20 of 184The Ring programming language version 1.5.3 book - Part 20 of 184
The Ring programming language version 1.5.3 book - Part 20 of 184
 
バイオインフォ分野におけるtidyなデータ解析の最新動向
バイオインフォ分野におけるtidyなデータ解析の最新動向バイオインフォ分野におけるtidyなデータ解析の最新動向
バイオインフォ分野におけるtidyなデータ解析の最新動向
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
Ptyhon 教學 002 程式流程控制(while-for)
Ptyhon 教學 002 程式流程控制(while-for)Ptyhon 教學 002 程式流程控制(while-for)
Ptyhon 教學 002 程式流程控制(while-for)
 
The Ring programming language version 1.3 book - Part 12 of 88
The Ring programming language version 1.3 book - Part 12 of 88The Ring programming language version 1.3 book - Part 12 of 88
The Ring programming language version 1.3 book - Part 12 of 88
 
MFC Prog
MFC ProgMFC Prog
MFC Prog
 
Linux Command Line Multitasking
Linux Command Line MultitaskingLinux Command Line Multitasking
Linux Command Line Multitasking
 
Inc decsourcefile
Inc decsourcefileInc decsourcefile
Inc decsourcefile
 

Similar to Kelompok 4

2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointerskinan keshkeh
 
#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docxajoy21
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignmentsreekanth3dce
 
Project of data structure
Project of data structureProject of data structure
Project of data structureUmme habiba
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfforladies
 
data structure and algorithm.pdf
data structure and algorithm.pdfdata structure and algorithm.pdf
data structure and algorithm.pdfAsrinath1
 
Slide 11_2.ppt Data structure and sslgorithmd slides of stacka nd trees
Slide 11_2.ppt Data structure and sslgorithmd slides of stacka nd treesSlide 11_2.ppt Data structure and sslgorithmd slides of stacka nd trees
Slide 11_2.ppt Data structure and sslgorithmd slides of stacka nd treesuraja6043
 
#includeiostream#includecctypeusing namespace std;cl.docx
#includeiostream#includecctypeusing namespace std;cl.docx#includeiostream#includecctypeusing namespace std;cl.docx
#includeiostream#includecctypeusing namespace std;cl.docxkatherncarlyle
 

Similar to Kelompok 4 (20)

Stack and queue
Stack and queueStack and queue
Stack and queue
 
Stack prgs
Stack prgsStack prgs
Stack prgs
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
 
#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
week-17x
week-17xweek-17x
week-17x
 
week-18x
week-18xweek-18x
week-18x
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignment
 
Project of data structure
Project of data structureProject of data structure
Project of data structure
 
Stack of Data structure
Stack of Data structureStack of Data structure
Stack of Data structure
 
Algoritma
AlgoritmaAlgoritma
Algoritma
 
Data Structure
Data StructureData Structure
Data Structure
 
week-15x
week-15xweek-15x
week-15x
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
 
stack (1).pptx
stack (1).pptxstack (1).pptx
stack (1).pptx
 
data structure and algorithm.pdf
data structure and algorithm.pdfdata structure and algorithm.pdf
data structure and algorithm.pdf
 
Slide 11_2.ppt Data structure and sslgorithmd slides of stacka nd trees
Slide 11_2.ppt Data structure and sslgorithmd slides of stacka nd treesSlide 11_2.ppt Data structure and sslgorithmd slides of stacka nd trees
Slide 11_2.ppt Data structure and sslgorithmd slides of stacka nd trees
 
Stack array
Stack arrayStack array
Stack array
 
Stack
StackStack
Stack
 
#includeiostream#includecctypeusing namespace std;cl.docx
#includeiostream#includecctypeusing namespace std;cl.docx#includeiostream#includecctypeusing namespace std;cl.docx
#includeiostream#includecctypeusing namespace std;cl.docx
 

Kelompok 4

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. STACK (TUMPUKAN)  Pengertian Stack  Stack adalah kumpulan data yang dapat diletakkan data lain di atasnya.  Perlu diingat bahwa kita hanya bisa menambah dan menghapus elemennya dari ujung atas saja. Proses seperti ini disebut juga Last In First Out ( LIFO ). .
  • 8. Operasi Pada Stack  Inisialisasi Yaitu membuat stack dalam keadaan kosong.  Push Yaitu Proses memasukkan elemen baru pada stack  Pop Yaitu mengambil elemen dari stack.  Size Yaitu operasi menetahui jumlah elemen stack.  Empty Yaitu untuk mengetahui stack kosong atau tidak.  Full Yaitu mengetahui status stack
  • 9. Uses crt; Listning Program STACK const max = 10; var top,i : byte; pil,tem,E : char; stack : array [1..max] of char; procedure pushanim; begin for i :=1 to 18 do begin gotoxy(23+i,7); write(tem); {Delay(30);} gotoxy(23,7); clreol; end; for i:=1 to 14-top do begin {delay(30);} gotoxy(41,6+i); write(' '); gotoxy(41,7+i); write(tem); end; end;
  • 10. procedure popanim(tem:char); begin for i:=1 to 14-top do begin {delay(30);} gotoxy(41,22-i-top); write(' '); gotoxy(41,21-i-top); write(tem); end; for i:=1 to 19 do begin gotoxy(40+i,7); write(tem); {delay(30);} gotoxy(16,7); clreol; end; end; procedure push(e:char); begin inc(top); stack[top] :=e; pushanim; end;
  • 11. procedure pop(e:char); begin if top<> 0 then begin E:=stack[top];popanim(e); dec(top); end else begin gotoxy(1,7); write('stack telah kosong'); readkey; gotoxy(1,7); clreol; end; end; begin clrscr; writeln('ANIMASI STACK'); writeln('1. PUSH (MASUKKAN DATA)'); writeln('2. POP (MENGHAPUS)‘); writeln('3. QUIT (KELUAR)'); writeln('Pilihan anda[1/2/3] = '); gotoxy(49,6);write(''); gotoxy(49,8);write('/'); gotoxy(37,10);write(' /'); for i:=1 to 11 do begin
  • 12. gotoxy(38,10+i); if i=11 then write('|_____|')else write ('| |'); end; top := 0; repeat gotoxy(23,5);clreol; pil := readkey;write(pil); if pil ='1' then begin if top<> max then begin gotoxy(1,7);write('Masukkan satu Huruf = '); tem := readkey;write(tem); push(tem); gotoxy(1,7);clreol; end else begin gotoxy(1,7);write('Stack sudah penuh');readkey; gotoxy(1,7);clreol; end; end else if pil='2' then pop(tem); until pil='3'; end.