STRUKTUR DATA PERTEMUAN 5

 Nama              : Abdul Ajiji  

NIM                 : 191011401517

Kelas              : 03TPLE021

*Pertemuan 5 

 

1. Susunlah program untuk menginput data dari keyboard terus menerus hingga stack1 penuh 

2. Susunlah program untuk menginput data dari keyboard terus menerus hingga stack2 penuh 

3. Susunlah program untuk menghapus stack1 hingga kosong 

4. Susunlah program untuk menghapus stack2 hingga kosong 

Program : 

tes.cpp 

HNM 

in oN 00 

#include<iostream#include<stdio.h#include<conio.h#include<stdlib.husing namespacstd#define 10 char P[]={'>','','','','',''}inS[n]mov[2],X,Y,pil=0int #top1"top2#dasari*dasar2"helpI

1A 

11 

 

NM 

voiawal(

top1=&S[-1]top2=&S[n]dasar1=&S[-1]dasar2=&S[n]helpI=&S[-1]

15 

16 

18 

19 

voipushi(int x)

topl=top1+1

*topl=x

22 

voipush2(int y)

top2=top2-1*top2=y

25 

26 

27 

voipop1

X=#top1#top1=0topl=top1-1

ה 

void pop20 

Y="top2*top2=0top2=to2+1

ה 

Nm t

ה 

ה 

3

37 

58 

int BisaDiisi(int k

if(top2-top1>k

retur1else 

return 0

39 40 

42 

int BisaDiambil1(

if(topl>dasariretur1else return 0

46 47 48 

49 

int BisaDiambil2(if(top2<dasar2

return 1els

return 0

niin inn HNM 

======"<<endl

5

void tampil(

cout<<"\n===============DatMenjad======= while(helpI!=(dasar2-1)helpI++cout<<*helpl<<"

59 

68 

===================================EEEEEEEEEEEE=

Vendi 

cout<<"\n========= 

helpI=&S[-1]

61 

63 

65 

======"<<endl

66 

6

voitampilMenu(

system("cls")cout<<"===========cout<<"1Isstack (kiri)"<<endlcout<<"2Isi stac(kanan)"<<endlcout<<"3Isi kedustack"<<endlcout<<"4Pop stack 1"<<endlcout<<"5Pop stac2"<<endlcout<<"6Pop kedustack"<<endlcout<<"========================== 

it<<"Pilihan anda 

69 

7

Nm 

in 

Komentar