SlideShare a Scribd company logo
1 of 50
STACK LINIER Contoh Program dan Penjelasannya Oleh Achmad Solichin Assisten Laboratorium Komputer FTI  Universitas Budi Luhur 08 April 2004
[object Object],[object Object],[object Object],[object Object],[object Object]
#include "stdio.h" #include "conio.h" #include "stdlib.h" #include "ctype.h" void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil; HEADER FUNGSI
#include "stdio.h" #include "conio.h" #include "stdlib.h" #include "ctype.h" void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil; DEKLARASI FUNGSI push();
DEKLARASI FUNGSI pop(); #include "stdio.h" #include "conio.h" #include "stdlib.h" #include "ctype.h" void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil;
DEKLARASI FUNGSI tampil(); #include "stdio.h" #include "conio.h" #include "stdlib.h" #include "ctype.h" void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil;
DEKLARASI FUNGSI reset(); #include "stdio.h" #include "conio.h" #include "stdlib.h" #include "ctype.h" void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil;
DEKLARASI stack x[5],  variabel dasar, atas, pil  dan bil #include "stdio.h" #include "conio.h" #include "stdlib.h" #include "ctype.h" void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil;
void main() { menu : clrscr(); gotoxy(25,3);  printf("===================="); gotoxy(25,4);  printf(“ Menu pilihan :    "); gotoxy(25,5);  printf("===================="); gotoxy(25,6);  printf(" 1. Push "); gotoxy(25,7);  printf(" 2. Pop ");
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],FUNGSI main();
DEKLARASI LABEL void main() { menu : clrscr(); gotoxy(25,3);  printf("===================="); gotoxy(25,4);  printf(“ Menu pilihan :    "); gotoxy(25,5);  printf("===================="); gotoxy(25,6);  printf(" 1. Push "); gotoxy(25,7);  printf(" 2. Pop ");
MEMBERSIHKAN LAYAR void main() { menu : clrscr(); gotoxy(25,3);  printf("===================="); gotoxy(25,4);  printf(“ Menu pilihan :    "); gotoxy(25,5);  printf("===================="); gotoxy(25,6);  printf(" 1. Push "); gotoxy(25,7);  printf(" 2. Pop ");
MEMINDAHKAN CURSOR  KE BARIS 25 , KOLOM 3 void main() { menu : clrscr(); gotoxy(25,3);  printf("===================="); gotoxy(25,4);  printf(“ Menu pilihan :    "); gotoxy(25,5);  printf("===================="); gotoxy(25,6);  printf(" 1. Push "); gotoxy(25,7);  printf(" 2. Pop "); 3 25
gotoxy(25,8);  printf("3. Preview "); gotoxy(25,9);  printf("4. Clear "); gotoxy(25,10);  printf("5. Exit "); gotoxy(25,11); printf("==============="); gotoxy(25,12);  printf("Masukkan pilihan : "); scanf("%i", &pil);
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
gotoxy(25,8);  printf("3. Preview "); gotoxy(25,9);  printf("4. Clear "); gotoxy(25,10);  printf("5. Exit "); gotoxy(25,11); printf("==============="); gotoxy(25,12);  printf("Masukkan pilihan : "); scanf("%i", &pil); Masukkan Pilihan
gotoxy(25,8);  printf("3. Preview "); gotoxy(25,9);  printf("4. Clear "); gotoxy(25,10);  printf("5. Exit "); gotoxy(25,11); printf("==============="); gotoxy(25,12);  printf("Masukkan pilihan : "); scanf("%i", &pil); MEMINTA INPUTAN  BILANGAN  INTEGER DAN  DIMASUKKAN  DALAM VARIABEL  pil
switch(pil) {  case 1 : gotoxy(25,13);   printf("Masukkan bil = ");     scanf("%i", &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; }
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],STRUKTUR  switch … case  AKAN  MEMERIKSA ISI  VARIABEL  pil  YANG  AKAN MENENTUKAN  PERINTAH MANA YANG DILAKSANAKAN Bentuk umum : switch(pilihan) { case 1 : <statemen>;   break; case 2 : <statemen>;   break; …… default : <statemen>; }
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } JIKA ISI VARIABEL  pil=1 MAKA STATEMENT DALAM BLOK INI AKAN DILAKSANAKAN
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } MASUKKAN BILANGAN YANG AKAN MASUK KE STACK
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } MEMINTA INPUTAN  BILANGAN  INTEGER DAN  DIMASUKKAN  DALAM VARIABEL  bil
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } PANGGIL FUNGSI  push()  YANG  MENGINPUT ISI VARIABEL BIL KE DALAM STACK X
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } break;   AKAN KELUAR DARI  switch  SEHINGGA PERINTAH YANG ADA DI BAWAHNYA TIDAK AKAN DILAKSANAKAN
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } JIKA NILAI VARIABEL  pil=2  MAKA PANGGIL  FUNGSI  pop()  UNTUK  MENGELUARKAN ISI STACK
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } JIKA NILAI VARIABEL  pil=3  MAKA PANGGIL  FUNGSI  tampil()  UNTUK  MENAMPILKAN ISI STACK
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } JIKA NILAI VARIABEL  pil=4  MAKA PANGGIL  FUNGSI  reset()  UNTUK  MENGEMBALIKAN ISI VARIABEL atas dan  dasar
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } JIKA NILAI VARIABEL  pil=5  MAKA PANGGIL  FUNGSI  exit(0)  DIMANA PROGRAM AKAN  SELESAI
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } MENUJU KE LABEL  menu
switch(pil) {  case 1 : gotoxy(25,13);   printf(&quot;Masukkan bil = &quot;);     scanf(&quot;%i&quot;, &bil);   push();   getch();   break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } AKHIR FUNGSI  main()
void push() {  if(atas<5) {  x[atas] = bil; atas++; gotoxy(25,14);    printf(&quot;%i telah masuk&quot;,bil); tampil(); } else  {   gotoxy(25,14);   printf(&quot;Stack penuh&quot;);  } } FLOWCHART PUSH() atas<5 x[atas]=bil atas++ penuh berhasil
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],FUNGSI  push()  YANG AKAN MENAMBAHKAN BILANGAN YANG  DIINPUT KE DALAM STACK
void push() {  if(atas<5) {  x[atas] = bil; atas++; gotoxy(25,14);    printf(&quot;%i telah masuk&quot;,bil); tampil(); } else  {   gotoxy(25,14);   printf(&quot;Stack penuh&quot;);  } } DALAM PROSES  push() PERTAMA KALI DIPE- RIKSA APAKAH STACK  SUDAH PENUH. JIKA  atas  MASIH KURANG  DARI 5 (JUMLAH MAX STACK) MAKA STACK  MASIH BISA DIISI
void push() {  if(atas<5) {  x[atas] = bil; atas++; gotoxy(25,14);    printf(&quot;%i telah masuk&quot;,bil); tampil(); } else  {   gotoxy(25,14);   printf(&quot;Stack penuh&quot;);  } } ISI VARIABEL  bil DISALIN KE STACK  x  INDEX YANG KE- atas
void push() {  if(atas<5) {  x[atas] = bil; atas++; gotoxy(25,14);    printf(&quot;%i telah masuk&quot;,bil); tampil(); } else  {   gotoxy(25,14);   printf(&quot;Stack penuh&quot;);  } } POINTER  atas  DIGESER KE KANAN.  atas = atas+1
void push() {  if(atas<5) {  x[atas] = bil; atas++; gotoxy(25,14);    printf(&quot;%i telah masuk&quot;,bil); tampil(); } else  {   gotoxy(25,14);   printf(&quot;Stack penuh&quot;);  } } NYATAKAN BAHWA ISI VARIABLE  bil TELAH MASUK KE STACK
void push() {  if(atas<5) {  x[atas] = bil; atas++; gotoxy(25,14);    printf(&quot;%i telah masuk&quot;,bil); tampil(); } else  {   gotoxy(25,14);   printf(&quot;Stack penuh&quot;);  } } PANGGIL FUNGSI  tampil()  UNTUK ME- NAMPILKAN ISI STACK
void push() {  if(atas<5) {  x[atas] = bil; atas++; gotoxy(25,14);    printf(&quot;%i telah masuk&quot;,bil); tampil(); } else  {   gotoxy(25,14);   printf(&quot;Stack penuh&quot;);  } } NYATAKAN STACK  PENUH JIKA KONDISI  ATAS<5 TIDAK  TERPENUHI
void pop() {  if(atas>0) {  atas --;   bil = x[atas];   gotoxy(25,13);    printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13);    printf(&quot;Stack kosong&quot;); } getch(); } FLOWCHART POP() atas>5 atas -- bil=x[atas] kosong terhapus
void pop() {  if(atas>0) {  atas --;   bil = x[atas];   gotoxy(25,13);    printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13);    printf(&quot;Stack kosong&quot;); } getch(); } FUNGSI  pop()  YANG AKAN MENGELUARKAN BILANGAN DALAM STACK SATU PER SATU
void pop() {  if(atas>0) {  atas --;   bil = x[atas];   gotoxy(25,13);    printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13);    printf(&quot;Stack kosong&quot;); } getch(); } DALAM PROSES  pop() PERTAMA KALI DIPE- RIKSA APAKAH STACK  KOSONG. JIKA  atas   MASIH LEBIH BESAR DARI 0 (NILAI AWAL  atas ) MAKA STACK  MASIH ADA ISINYA
void pop() {  if(atas>0) {  atas --;   bil = x[atas];   gotoxy(25,13);    printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13);    printf(&quot;Stack kosong&quot;); } getch(); } POINTER  atas  DIGESER KE KIRI.  atas = atas-1
void pop() {  if(atas>0) {  atas --;   bil = x[atas];   gotoxy(25,13);    printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13);    printf(&quot;Stack kosong&quot;); } getch(); } ISI VARIABEL  x[atas] DISALIN KE VARIABEL  bil
void pop() {  if(atas>0) {  atas --;   bil = x[atas];   gotoxy(25,13);    printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13);    printf(&quot;Stack kosong&quot;); } getch(); } NYATAKAN BAHWA ISI VARIABLE  bil TELAH DIHAPUS DARI STACK
void pop() {  if(atas>0) {  atas --;   bil = x[atas];   gotoxy(25,13);    printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13);    printf(&quot;Stack kosong&quot;); } getch(); } NYATAKAN STACK  KOSONG JIKA KONDISI  atas>0  TIDAK  TERPENUHI
void tampil() {  int i,baris; i = 0;baris=17; gotoxy(25,15); printf(&quot;==================&quot;); gotoxy(25,16);  printf(&quot;Isi stack :  &quot;); while(i<atas) {  gotoxy(25,baris);   printf(&quot;x[%i] = %2i&quot;, i, x[i]); i++; baris++; } gotoxy(25,baris); printf(&quot;=================&quot;); gotoxy(25,++baris);  printf(&quot;Press any key ....&quot;); } FLOWCHART TAMPIL() int i=0; i<atas i++; cetak isi stack
void tampil() {  int i,baris; i = 0;baris=17; gotoxy(25,15); printf(&quot;==================&quot;); gotoxy(25,16);  printf(&quot;Isi stack :  &quot;); while(i<atas) {  gotoxy(25,baris);   printf(&quot;º x = %2i&quot;, x[i]); i++; baris++; } gotoxy(25,baris); printf(&quot;=================&quot;); gotoxy(25,++baris);  printf(&quot;Press any key ....&quot;); } PERULANGAN UNTUK MENAMPILKAN ISI STACK. PERULANGAN DIMULAI DARI  i=0 SELAMA  i<atas
void reset()   { atas = 0; dasar = 0; printf(&quot;Stack telah dikosongkan.....&quot;); } FUNGSI  reset()  UNTUK MENGEMBALIKAN STACK KE KEADAAN SEMUA(AWAL) DIMANA  atas=0  DAN  dasar=0
SELESAI
Alhamdulillahi Robbil ‘Alamiin

More Related Content

Viewers also liked

Vaststellen van didactische bekwaamheid tijdens de LIO-stage
Vaststellen van didactische bekwaamheid tijdens de LIO-stageVaststellen van didactische bekwaamheid tijdens de LIO-stage
Vaststellen van didactische bekwaamheid tijdens de LIO-stageErik Roelofs
 
Diretrizescurriculares 2012
Diretrizescurriculares 2012Diretrizescurriculares 2012
Diretrizescurriculares 2012angelafreire
 
A Regulação pública da saúde no Estado brasileiro
A Regulação pública da saúde no Estado brasileiroA Regulação pública da saúde no Estado brasileiro
A Regulação pública da saúde no Estado brasileiroRodrigo Zardo
 
Cursobasico0910
Cursobasico0910Cursobasico0910
Cursobasico0910SEIEM
 
Contribuições aos modelos de maturidade em gestão por processos e de excelênc...
Contribuições aos modelos de maturidade em gestão por processos e de excelênc...Contribuições aos modelos de maturidade em gestão por processos e de excelênc...
Contribuições aos modelos de maturidade em gestão por processos e de excelênc...Felipe Guedes Pinheiro
 
Atps de direito civil
Atps de direito civilAtps de direito civil
Atps de direito civilWilliam Luz
 
Politie en publiek_eindrapport
Politie en publiek_eindrapportPolitie en publiek_eindrapport
Politie en publiek_eindrapportFrank Smilda
 
Cuestionario certificacion laboral
Cuestionario certificacion laboralCuestionario certificacion laboral
Cuestionario certificacion laboralJuan Lemos
 
Wa early childhood_handbook
Wa early childhood_handbookWa early childhood_handbook
Wa early childhood_handbookshawnamali
 
Análise sobre os signos, significados e significantes
Análise sobre os signos, significados e significantesAnálise sobre os signos, significados e significantes
Análise sobre os signos, significados e significantesJean Michel Gallo Soldatelli
 
Plan de acción de pensamiento critico
Plan de acción de pensamiento criticoPlan de acción de pensamiento critico
Plan de acción de pensamiento criticoRo Va Que
 
Estereótipos femininos fomentados pelos meios de comunicação
Estereótipos femininos fomentados pelos meios de comunicaçãoEstereótipos femininos fomentados pelos meios de comunicação
Estereótipos femininos fomentados pelos meios de comunicaçãoCassia Barbosa
 

Viewers also liked (20)

Vaststellen van didactische bekwaamheid tijdens de LIO-stage
Vaststellen van didactische bekwaamheid tijdens de LIO-stageVaststellen van didactische bekwaamheid tijdens de LIO-stage
Vaststellen van didactische bekwaamheid tijdens de LIO-stage
 
Diretrizescurriculares 2012
Diretrizescurriculares 2012Diretrizescurriculares 2012
Diretrizescurriculares 2012
 
A Regulação pública da saúde no Estado brasileiro
A Regulação pública da saúde no Estado brasileiroA Regulação pública da saúde no Estado brasileiro
A Regulação pública da saúde no Estado brasileiro
 
Normasicontec
Normasicontec Normasicontec
Normasicontec
 
Cursobasico0910
Cursobasico0910Cursobasico0910
Cursobasico0910
 
Contribuições aos modelos de maturidade em gestão por processos e de excelênc...
Contribuições aos modelos de maturidade em gestão por processos e de excelênc...Contribuições aos modelos de maturidade em gestão por processos e de excelênc...
Contribuições aos modelos de maturidade em gestão por processos e de excelênc...
 
Seminario rediseño de procesos
Seminario rediseño de procesosSeminario rediseño de procesos
Seminario rediseño de procesos
 
Atps de direito civil
Atps de direito civilAtps de direito civil
Atps de direito civil
 
Trabajo .. riesgos !!
Trabajo .. riesgos !!Trabajo .. riesgos !!
Trabajo .. riesgos !!
 
Politie en publiek_eindrapport
Politie en publiek_eindrapportPolitie en publiek_eindrapport
Politie en publiek_eindrapport
 
Prof.
Prof.Prof.
Prof.
 
Cuestionario certificacion laboral
Cuestionario certificacion laboralCuestionario certificacion laboral
Cuestionario certificacion laboral
 
Nombr
NombrNombr
Nombr
 
Wa early childhood_handbook
Wa early childhood_handbookWa early childhood_handbook
Wa early childhood_handbook
 
Análise sobre os signos, significados e significantes
Análise sobre os signos, significados e significantesAnálise sobre os signos, significados e significantes
Análise sobre os signos, significados e significantes
 
Manual fondos
Manual fondosManual fondos
Manual fondos
 
Análise da Propaganda de Bebidas Alcoólicas
Análise da Propaganda de Bebidas AlcoólicasAnálise da Propaganda de Bebidas Alcoólicas
Análise da Propaganda de Bebidas Alcoólicas
 
Plan de acción de pensamiento critico
Plan de acción de pensamiento criticoPlan de acción de pensamiento critico
Plan de acción de pensamiento critico
 
Estereótipos femininos fomentados pelos meios de comunicação
Estereótipos femininos fomentados pelos meios de comunicaçãoEstereótipos femininos fomentados pelos meios de comunicação
Estereótipos femininos fomentados pelos meios de comunicação
 
[2014년 개정판] 공공정책, 책상에서 현장으로
[2014년 개정판] 공공정책, 책상에서 현장으로[2014년 개정판] 공공정책, 책상에서 현장으로
[2014년 개정판] 공공정책, 책상에서 현장으로
 

More from Achmad Solichin

Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)Achmad Solichin
 
Materi Webinar Web 3.0 (16 Juli 2022)
Materi Webinar Web 3.0 (16 Juli 2022)Materi Webinar Web 3.0 (16 Juli 2022)
Materi Webinar Web 3.0 (16 Juli 2022)Achmad Solichin
 
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)Achmad Solichin
 
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)Achmad Solichin
 
Webinar PHP-ID: Machine Learning dengan PHP
Webinar PHP-ID: Machine Learning dengan PHPWebinar PHP-ID: Machine Learning dengan PHP
Webinar PHP-ID: Machine Learning dengan PHPAchmad Solichin
 
Webinar Data Mining dengan Rapidminer | Universitas Budi Luhur
Webinar Data Mining dengan Rapidminer | Universitas Budi LuhurWebinar Data Mining dengan Rapidminer | Universitas Budi Luhur
Webinar Data Mining dengan Rapidminer | Universitas Budi LuhurAchmad Solichin
 
TREN DAN IDE RISET BIDANG DATA MINING TERBARU
TREN DAN IDE RISET BIDANG DATA MINING TERBARUTREN DAN IDE RISET BIDANG DATA MINING TERBARU
TREN DAN IDE RISET BIDANG DATA MINING TERBARUAchmad Solichin
 
Metodologi Riset: Literature Review
Metodologi Riset: Literature ReviewMetodologi Riset: Literature Review
Metodologi Riset: Literature ReviewAchmad Solichin
 
Materi Seminar: Artificial Intelligence dengan PHP
Materi Seminar: Artificial Intelligence dengan PHPMateri Seminar: Artificial Intelligence dengan PHP
Materi Seminar: Artificial Intelligence dengan PHPAchmad Solichin
 
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan RadiasiPercobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan RadiasiAchmad Solichin
 
Metodologi Riset: Literature Review
Metodologi Riset: Literature ReviewMetodologi Riset: Literature Review
Metodologi Riset: Literature ReviewAchmad Solichin
 
Depth First Search (DFS) pada Graph
Depth First Search (DFS) pada GraphDepth First Search (DFS) pada Graph
Depth First Search (DFS) pada GraphAchmad Solichin
 
Breadth First Search (BFS) pada Graph
Breadth First Search (BFS) pada GraphBreadth First Search (BFS) pada Graph
Breadth First Search (BFS) pada GraphAchmad Solichin
 
Binary Search Tree (BST) - Algoritma dan Struktur Data
Binary Search Tree (BST) - Algoritma dan Struktur DataBinary Search Tree (BST) - Algoritma dan Struktur Data
Binary Search Tree (BST) - Algoritma dan Struktur DataAchmad Solichin
 
Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0Achmad Solichin
 
Seminar: Become a Reliable Web Programmer
Seminar: Become a Reliable Web ProgrammerSeminar: Become a Reliable Web Programmer
Seminar: Become a Reliable Web ProgrammerAchmad Solichin
 
The Big 5: Future IT Trends
The Big 5: Future IT TrendsThe Big 5: Future IT Trends
The Big 5: Future IT TrendsAchmad Solichin
 
Seminar: PHP Developer for Dummies
Seminar: PHP Developer for DummiesSeminar: PHP Developer for Dummies
Seminar: PHP Developer for DummiesAchmad Solichin
 
Pertemuan 1 - Algoritma dan Struktur Data 1
Pertemuan 1 - Algoritma dan Struktur Data 1Pertemuan 1 - Algoritma dan Struktur Data 1
Pertemuan 1 - Algoritma dan Struktur Data 1Achmad Solichin
 

More from Achmad Solichin (20)

Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
 
Materi Webinar Web 3.0 (16 Juli 2022)
Materi Webinar Web 3.0 (16 Juli 2022)Materi Webinar Web 3.0 (16 Juli 2022)
Materi Webinar Web 3.0 (16 Juli 2022)
 
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
 
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
 
Webinar PHP-ID: Machine Learning dengan PHP
Webinar PHP-ID: Machine Learning dengan PHPWebinar PHP-ID: Machine Learning dengan PHP
Webinar PHP-ID: Machine Learning dengan PHP
 
Webinar Data Mining dengan Rapidminer | Universitas Budi Luhur
Webinar Data Mining dengan Rapidminer | Universitas Budi LuhurWebinar Data Mining dengan Rapidminer | Universitas Budi Luhur
Webinar Data Mining dengan Rapidminer | Universitas Budi Luhur
 
TREN DAN IDE RISET BIDANG DATA MINING TERBARU
TREN DAN IDE RISET BIDANG DATA MINING TERBARUTREN DAN IDE RISET BIDANG DATA MINING TERBARU
TREN DAN IDE RISET BIDANG DATA MINING TERBARU
 
Metodologi Riset: Literature Review
Metodologi Riset: Literature ReviewMetodologi Riset: Literature Review
Metodologi Riset: Literature Review
 
Materi Seminar: Artificial Intelligence dengan PHP
Materi Seminar: Artificial Intelligence dengan PHPMateri Seminar: Artificial Intelligence dengan PHP
Materi Seminar: Artificial Intelligence dengan PHP
 
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan RadiasiPercobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
 
Metodologi Riset: Literature Review
Metodologi Riset: Literature ReviewMetodologi Riset: Literature Review
Metodologi Riset: Literature Review
 
Depth First Search (DFS) pada Graph
Depth First Search (DFS) pada GraphDepth First Search (DFS) pada Graph
Depth First Search (DFS) pada Graph
 
Breadth First Search (BFS) pada Graph
Breadth First Search (BFS) pada GraphBreadth First Search (BFS) pada Graph
Breadth First Search (BFS) pada Graph
 
Binary Search Tree (BST) - Algoritma dan Struktur Data
Binary Search Tree (BST) - Algoritma dan Struktur DataBinary Search Tree (BST) - Algoritma dan Struktur Data
Binary Search Tree (BST) - Algoritma dan Struktur Data
 
Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0Computer Vision di Era Industri 4.0
Computer Vision di Era Industri 4.0
 
Seminar: Become a Reliable Web Programmer
Seminar: Become a Reliable Web ProgrammerSeminar: Become a Reliable Web Programmer
Seminar: Become a Reliable Web Programmer
 
The Big 5: Future IT Trends
The Big 5: Future IT TrendsThe Big 5: Future IT Trends
The Big 5: Future IT Trends
 
Modern PHP Developer
Modern PHP DeveloperModern PHP Developer
Modern PHP Developer
 
Seminar: PHP Developer for Dummies
Seminar: PHP Developer for DummiesSeminar: PHP Developer for Dummies
Seminar: PHP Developer for Dummies
 
Pertemuan 1 - Algoritma dan Struktur Data 1
Pertemuan 1 - Algoritma dan Struktur Data 1Pertemuan 1 - Algoritma dan Struktur Data 1
Pertemuan 1 - Algoritma dan Struktur Data 1
 

Recently uploaded

Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmibookbahareshariat
 
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...Eesti Loodusturism
 
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdf
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdfمحاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdf
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdfKhaled Elbattawy
 
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmibookbahareshariat
 
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmibookbahareshariat
 

Recently uploaded (6)

Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 4 By SadurshSharia Mufti Amjad Ali Azmi
 
Energy drink .
Energy drink                           .Energy drink                           .
Energy drink .
 
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...
Saunanaine_Helen Moppel_JUHENDATUD SAUNATEENUSE JA LOODUSMATKA SÜNERGIA_strat...
 
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdf
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdfمحاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdf
محاضرات الاحصاء التطبيقي لطلاب علوم الرياضة.pdf
 
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 1 By SadurshSharia Mufti Amjad Ali Azmi
 
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali AzmiBahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmi
Bahare Shariat Jild 2 By SadurshSharia Mufti Amjad Ali Azmi
 

Stack Linier 2

  • 1. STACK LINIER Contoh Program dan Penjelasannya Oleh Achmad Solichin Assisten Laboratorium Komputer FTI Universitas Budi Luhur 08 April 2004
  • 2.
  • 3. #include &quot;stdio.h&quot; #include &quot;conio.h&quot; #include &quot;stdlib.h&quot; #include &quot;ctype.h&quot; void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil; HEADER FUNGSI
  • 4. #include &quot;stdio.h&quot; #include &quot;conio.h&quot; #include &quot;stdlib.h&quot; #include &quot;ctype.h&quot; void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil; DEKLARASI FUNGSI push();
  • 5. DEKLARASI FUNGSI pop(); #include &quot;stdio.h&quot; #include &quot;conio.h&quot; #include &quot;stdlib.h&quot; #include &quot;ctype.h&quot; void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil;
  • 6. DEKLARASI FUNGSI tampil(); #include &quot;stdio.h&quot; #include &quot;conio.h&quot; #include &quot;stdlib.h&quot; #include &quot;ctype.h&quot; void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil;
  • 7. DEKLARASI FUNGSI reset(); #include &quot;stdio.h&quot; #include &quot;conio.h&quot; #include &quot;stdlib.h&quot; #include &quot;ctype.h&quot; void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil;
  • 8. DEKLARASI stack x[5], variabel dasar, atas, pil dan bil #include &quot;stdio.h&quot; #include &quot;conio.h&quot; #include &quot;stdlib.h&quot; #include &quot;ctype.h&quot; void push(); void pop(); void tampil(); void reset(); int x[5],dasar=0; int atas=0,pil,bil;
  • 9. void main() { menu : clrscr(); gotoxy(25,3); printf(&quot;====================&quot;); gotoxy(25,4); printf(“ Menu pilihan : &quot;); gotoxy(25,5); printf(&quot;====================&quot;); gotoxy(25,6); printf(&quot; 1. Push &quot;); gotoxy(25,7); printf(&quot; 2. Pop &quot;);
  • 10.
  • 11. DEKLARASI LABEL void main() { menu : clrscr(); gotoxy(25,3); printf(&quot;====================&quot;); gotoxy(25,4); printf(“ Menu pilihan : &quot;); gotoxy(25,5); printf(&quot;====================&quot;); gotoxy(25,6); printf(&quot; 1. Push &quot;); gotoxy(25,7); printf(&quot; 2. Pop &quot;);
  • 12. MEMBERSIHKAN LAYAR void main() { menu : clrscr(); gotoxy(25,3); printf(&quot;====================&quot;); gotoxy(25,4); printf(“ Menu pilihan : &quot;); gotoxy(25,5); printf(&quot;====================&quot;); gotoxy(25,6); printf(&quot; 1. Push &quot;); gotoxy(25,7); printf(&quot; 2. Pop &quot;);
  • 13. MEMINDAHKAN CURSOR KE BARIS 25 , KOLOM 3 void main() { menu : clrscr(); gotoxy(25,3); printf(&quot;====================&quot;); gotoxy(25,4); printf(“ Menu pilihan : &quot;); gotoxy(25,5); printf(&quot;====================&quot;); gotoxy(25,6); printf(&quot; 1. Push &quot;); gotoxy(25,7); printf(&quot; 2. Pop &quot;); 3 25
  • 14. gotoxy(25,8); printf(&quot;3. Preview &quot;); gotoxy(25,9); printf(&quot;4. Clear &quot;); gotoxy(25,10); printf(&quot;5. Exit &quot;); gotoxy(25,11); printf(&quot;===============&quot;); gotoxy(25,12); printf(&quot;Masukkan pilihan : &quot;); scanf(&quot;%i&quot;, &pil);
  • 15.
  • 16. gotoxy(25,8); printf(&quot;3. Preview &quot;); gotoxy(25,9); printf(&quot;4. Clear &quot;); gotoxy(25,10); printf(&quot;5. Exit &quot;); gotoxy(25,11); printf(&quot;===============&quot;); gotoxy(25,12); printf(&quot;Masukkan pilihan : &quot;); scanf(&quot;%i&quot;, &pil); Masukkan Pilihan
  • 17. gotoxy(25,8); printf(&quot;3. Preview &quot;); gotoxy(25,9); printf(&quot;4. Clear &quot;); gotoxy(25,10); printf(&quot;5. Exit &quot;); gotoxy(25,11); printf(&quot;===============&quot;); gotoxy(25,12); printf(&quot;Masukkan pilihan : &quot;); scanf(&quot;%i&quot;, &pil); MEMINTA INPUTAN BILANGAN INTEGER DAN DIMASUKKAN DALAM VARIABEL pil
  • 18. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; }
  • 19.
  • 20. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } JIKA ISI VARIABEL pil=1 MAKA STATEMENT DALAM BLOK INI AKAN DILAKSANAKAN
  • 21. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } MASUKKAN BILANGAN YANG AKAN MASUK KE STACK
  • 22. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } MEMINTA INPUTAN BILANGAN INTEGER DAN DIMASUKKAN DALAM VARIABEL bil
  • 23. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } PANGGIL FUNGSI push() YANG MENGINPUT ISI VARIABEL BIL KE DALAM STACK X
  • 24. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } break; AKAN KELUAR DARI switch SEHINGGA PERINTAH YANG ADA DI BAWAHNYA TIDAK AKAN DILAKSANAKAN
  • 25. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } JIKA NILAI VARIABEL pil=2 MAKA PANGGIL FUNGSI pop() UNTUK MENGELUARKAN ISI STACK
  • 26. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } JIKA NILAI VARIABEL pil=3 MAKA PANGGIL FUNGSI tampil() UNTUK MENAMPILKAN ISI STACK
  • 27. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } JIKA NILAI VARIABEL pil=4 MAKA PANGGIL FUNGSI reset() UNTUK MENGEMBALIKAN ISI VARIABEL atas dan dasar
  • 28. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } JIKA NILAI VARIABEL pil=5 MAKA PANGGIL FUNGSI exit(0) DIMANA PROGRAM AKAN SELESAI
  • 29. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } MENUJU KE LABEL menu
  • 30. switch(pil) { case 1 : gotoxy(25,13); printf(&quot;Masukkan bil = &quot;); scanf(&quot;%i&quot;, &bil); push(); getch(); break; case 2 : pop(); break; case 3 : tampil(); getch(); break; case 4 : reset(); getch(); break; case 5 : exit(0); break; } goto menu; } AKHIR FUNGSI main()
  • 31. void push() { if(atas<5) { x[atas] = bil; atas++; gotoxy(25,14); printf(&quot;%i telah masuk&quot;,bil); tampil(); } else { gotoxy(25,14); printf(&quot;Stack penuh&quot;); } } FLOWCHART PUSH() atas<5 x[atas]=bil atas++ penuh berhasil
  • 32.
  • 33. void push() { if(atas<5) { x[atas] = bil; atas++; gotoxy(25,14); printf(&quot;%i telah masuk&quot;,bil); tampil(); } else { gotoxy(25,14); printf(&quot;Stack penuh&quot;); } } DALAM PROSES push() PERTAMA KALI DIPE- RIKSA APAKAH STACK SUDAH PENUH. JIKA atas MASIH KURANG DARI 5 (JUMLAH MAX STACK) MAKA STACK MASIH BISA DIISI
  • 34. void push() { if(atas<5) { x[atas] = bil; atas++; gotoxy(25,14); printf(&quot;%i telah masuk&quot;,bil); tampil(); } else { gotoxy(25,14); printf(&quot;Stack penuh&quot;); } } ISI VARIABEL bil DISALIN KE STACK x INDEX YANG KE- atas
  • 35. void push() { if(atas<5) { x[atas] = bil; atas++; gotoxy(25,14); printf(&quot;%i telah masuk&quot;,bil); tampil(); } else { gotoxy(25,14); printf(&quot;Stack penuh&quot;); } } POINTER atas DIGESER KE KANAN. atas = atas+1
  • 36. void push() { if(atas<5) { x[atas] = bil; atas++; gotoxy(25,14); printf(&quot;%i telah masuk&quot;,bil); tampil(); } else { gotoxy(25,14); printf(&quot;Stack penuh&quot;); } } NYATAKAN BAHWA ISI VARIABLE bil TELAH MASUK KE STACK
  • 37. void push() { if(atas<5) { x[atas] = bil; atas++; gotoxy(25,14); printf(&quot;%i telah masuk&quot;,bil); tampil(); } else { gotoxy(25,14); printf(&quot;Stack penuh&quot;); } } PANGGIL FUNGSI tampil() UNTUK ME- NAMPILKAN ISI STACK
  • 38. void push() { if(atas<5) { x[atas] = bil; atas++; gotoxy(25,14); printf(&quot;%i telah masuk&quot;,bil); tampil(); } else { gotoxy(25,14); printf(&quot;Stack penuh&quot;); } } NYATAKAN STACK PENUH JIKA KONDISI ATAS<5 TIDAK TERPENUHI
  • 39. void pop() { if(atas>0) { atas --; bil = x[atas]; gotoxy(25,13); printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13); printf(&quot;Stack kosong&quot;); } getch(); } FLOWCHART POP() atas>5 atas -- bil=x[atas] kosong terhapus
  • 40. void pop() { if(atas>0) { atas --; bil = x[atas]; gotoxy(25,13); printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13); printf(&quot;Stack kosong&quot;); } getch(); } FUNGSI pop() YANG AKAN MENGELUARKAN BILANGAN DALAM STACK SATU PER SATU
  • 41. void pop() { if(atas>0) { atas --; bil = x[atas]; gotoxy(25,13); printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13); printf(&quot;Stack kosong&quot;); } getch(); } DALAM PROSES pop() PERTAMA KALI DIPE- RIKSA APAKAH STACK KOSONG. JIKA atas MASIH LEBIH BESAR DARI 0 (NILAI AWAL atas ) MAKA STACK MASIH ADA ISINYA
  • 42. void pop() { if(atas>0) { atas --; bil = x[atas]; gotoxy(25,13); printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13); printf(&quot;Stack kosong&quot;); } getch(); } POINTER atas DIGESER KE KIRI. atas = atas-1
  • 43. void pop() { if(atas>0) { atas --; bil = x[atas]; gotoxy(25,13); printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13); printf(&quot;Stack kosong&quot;); } getch(); } ISI VARIABEL x[atas] DISALIN KE VARIABEL bil
  • 44. void pop() { if(atas>0) { atas --; bil = x[atas]; gotoxy(25,13); printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13); printf(&quot;Stack kosong&quot;); } getch(); } NYATAKAN BAHWA ISI VARIABLE bil TELAH DIHAPUS DARI STACK
  • 45. void pop() { if(atas>0) { atas --; bil = x[atas]; gotoxy(25,13); printf(&quot;%i telah dihapus&quot;,bil); } else { gotoxy(25,13); printf(&quot;Stack kosong&quot;); } getch(); } NYATAKAN STACK KOSONG JIKA KONDISI atas>0 TIDAK TERPENUHI
  • 46. void tampil() { int i,baris; i = 0;baris=17; gotoxy(25,15); printf(&quot;==================&quot;); gotoxy(25,16); printf(&quot;Isi stack : &quot;); while(i<atas) { gotoxy(25,baris); printf(&quot;x[%i] = %2i&quot;, i, x[i]); i++; baris++; } gotoxy(25,baris); printf(&quot;=================&quot;); gotoxy(25,++baris); printf(&quot;Press any key ....&quot;); } FLOWCHART TAMPIL() int i=0; i<atas i++; cetak isi stack
  • 47. void tampil() { int i,baris; i = 0;baris=17; gotoxy(25,15); printf(&quot;==================&quot;); gotoxy(25,16); printf(&quot;Isi stack : &quot;); while(i<atas) { gotoxy(25,baris); printf(&quot;º x = %2i&quot;, x[i]); i++; baris++; } gotoxy(25,baris); printf(&quot;=================&quot;); gotoxy(25,++baris); printf(&quot;Press any key ....&quot;); } PERULANGAN UNTUK MENAMPILKAN ISI STACK. PERULANGAN DIMULAI DARI i=0 SELAMA i<atas
  • 48. void reset() { atas = 0; dasar = 0; printf(&quot;Stack telah dikosongkan.....&quot;); } FUNGSI reset() UNTUK MENGEMBALIKAN STACK KE KEADAAN SEMUA(AWAL) DIMANA atas=0 DAN dasar=0