#include
#include
#define maks 5
using namespace std;
class Queue{
friend ostream& operator<<(ostream&, const Queue&); public : Queue(); int penuh(int); int kosong(int); void cetak(); void enqueue(char); char dequeue(); private : char A[maks]; int banyak; }; ostream& operator<<(ostream&out,const Queue& s) { cout<<"\nIsi Queue sebanyak : "<
if(banyak !=tempat)
for(int i=banyak; i>=tempat; i--)
A[i+1]=A[i];
A[tempat]=x;
banyak++;
}
}
char Queue::dequeue()
{
char temp=A[--banyak];
cout<<"\nDequeue elemen-->"<
A[banyak]='0';
return temp;
}
main(){
Queue p;
p.enqueue('b');
cout<
p.enqueue('d');
cout<
p.enqueue('c');
cout<
p.enqueue('e');
cout<
p.enqueue('a');
cout<
char x=p.dequeue();
cout<<"elemen yang di dequeue"<
cout<
{
system("PAUSE");
return EXIT_SUCCESS;
}
}
About Me
Statistik
Live Traffic Feed
Daftar Blog Teman
Link
Blogroll
Didukung
Followers
- Anak Indonesia Harapan Masa Depan (1)
- APBO (1)
- Basis Data (2)
- ERD (1)
- MySQL (1)
- Pendidikan (3)
- Peran Perbankan dan Koperasi dalam mendorong peningkatan kewirausahaan di Indonesia (1)
- PHP (2)
- Programing C++ (8)
- Sewa Ruang Kantor Jakarta Murah (1)
- Sistem Operasi (6)
- Struktur Data (1)
- Web Desain (4)
- Web Dinamis (2)
//achicha_01@yahoo.com
#include
#include
#define maks 5
#include
#include
using namespace std;
class Stack{
friend ostream& operator<<(ostream&, const Stack&); public: Stack(); int penuh(int); int kosong(int); void cetak(); void push(char); char pop(); void PrintMatchedPairs(char *expr); private: char A[maks]; int banyak; }; ostream& operator<<(ostream& out, const Stack& s) { cout << "\nIsi stack : "; for (int i=0;i< banyak =" 0;" i="0;" maks="" int="" return="" s="=" 0="" 1="" void="" cout=""><< "\nIsi stack : "; for (int i=0;i< i="banyak;">=0; i--)
A[i+1] = A[i];
A[0] = x;
banyak++; }
}
char Stack::pop()
{
cout <<"\nPop stack, elemen yang di-pop :" << A[0];
char temp=A[0];
for (int i=0;i
banyak--;
return temp;
}
void Stack::PrintMatchedPairs(char *expr){
int A[maks];
int j, length=strlen(expr);
for(int i=1;i<=length;i++){
if(expr[i-1]=='(');
else if (expr[i-1]==')')
cout << j << ' ' << i << endl;
}
}
int main(int argc, char *argv[])
{
Stack stack;
for (char c='a'; c<'d'; c++){
stack.push(c);
stack.cetak();
}
char expr[maks];
cout << "Type an expression of length at most " << maks << endl;
cin.getline(expr,maks);
cout << "The pairs of maytching parentheses in " << endl;
puts(expr);
cout << "are" << endl;
// PrintMatchedpairs(*expr);
char p = stack.pop();
stack.cetak();
cout << "\n\nCetak pakai overloading : " << stack;
system("PAUSE");
return EXIT_SUCCESS;
}
//achicha_01@yahoo.com
#include
#include
using namespace std;
//template
class Node{
friend class List;
friend ostream& operator<<(ostream&, const List&); public: Node(int& t,Node* p) : info(t), berikut(p){} protected: int info; Node *berikut; }; //template
class List{
friend ostream& operator<<(ostream&, const List&); public: List() : kepala(0){} ~List(); void sisip(int t); int hapus(char& t); int kosong() {return (kepala == 0);} void cetak(); protected: Node* kepala; Node* nodeBaru(int& t,Node* p) { Node* q = new Node(t,p); return q;} }; //template
ostream& operator<<(ostream& out, const List& k) { for (Node* p = k.kepala; p; p=p->berikut)
out <<>info << "->";
out << "*\n"; return out; } //template
List::~List()
{
Node* temp;
for (Node* p = kepala; p;)
{
temp = p;
p = p->berikut;
delete temp;
}
}
//template
void List::sisip(int t)
{
cout << p =" nodeBaru(t,kepala);" kepala =" p;" t="">
int List::hapus(char& t)
{
if (kosong()) return 0; //penghapusan gagal
t = kepala->info;
Node* p = kepala;
kepala = kepala->berikut;
delete p;
return 1; //penghapusan sukses
}
//template
void List::cetak()
{
for (Node* p = kepala; p; p=p->berikut)
cout <<>info << "->";
cout << "*\n";
}
int main()
{
List x;
char data;
x.sisip('a');
cout << x;
x.sisip('b');
cout << x;
x.sisip('c');
cout << x;
x.sisip('d');
cout << x;
for (int i=0; i<5; i++){
x.hapus(data);
cout << data << "dihapus dari list :";
cout << x;
}
system("PAUSE");
return EXIT_SUCCESS;
}