//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;
}
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)
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar