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.h> using namespace std; #define n 10 char P[]={'>','','','','',''}; int S[n], mov[2],X,Y,pil=0; int #top1, "top2, #dasari, *dasar2, "helpI;
1A
11
모
NM
void awal({
top1=&S[-1]; top2=&S[n]; dasar1=&S[-1]; dasar2=&S[n]; helpI=&S[-1];
15
16
18
19
void pushi(int x){
topl=top1+1;
*topl=x;
}
22 A
void push2(int y){
top2=top2-1; *top2=y;
25
26
27
void pop1{
X=#top1; #top1=0; topl=top1-1;
ה
void pop20 X
Y="top2; *top2=0; top2=top 2+1;
ה
Nm tu
ה
ה
36
37
58
int BisaDiisi(int k) {
if(top2-top1>k)
return 1; else
return 0;
39 40
42
int BisaDiambil1({
if(topl>dasari) return 1; else return 0;
46 47 48
49
int BisaDiambil2({ if(top2<dasar2)
return 1; else
return 0;
niin inn HNM
=
=
=
=
=
=
======"<<endl;
56
void tampil({
cout<<"\n================ Data Menjadi ======= while(helpI!=(dasar2-1)) { helpI++; cout<<*helpl<<" ";
59
68
===================================EEEEEEEEEEEE="
Vendi
cout<<"\n=========
helpI=&S[-1];
61
63 -
m
65
=
=
=
======"<<endl;
66
68
void tampilMenu({
system("cls"); cout<<"============ cout<<"1. Isi stack 1 (kiri)"<<endl; cout<<"2. Isi stack 2 (kanan)"<<endl; cout<<"3. Isi kedua stack"<<endl; cout<<"4. Pop stack 1"<<endl; cout<<"5. Pop stack 2"<<endl; cout<<"6. Pop kedua stack"<<endl; cout<<"==========================
it<<"Pilihan anda :
69
7@
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
"
e
n
n
Nm
n
in
Komentar
Posting Komentar