jam digital

WELCOME TO MY BLOG "VIRGO_BLOG'S

SELAMAT DATANG DI BLOG SAYA, SELAMAT MENGUNJUNGINYA DAN SELAMAT MEMBACA.

Minggu, 31 Oktober 2010

PROGRAM STACK

#include <cstdlib> #include <iostream> using namespace std; class Stack{ public: Stack(){ jum = 5; last = 0; } void push(int data){ if(jum > last){ a[last] = data; last = last + 1; } } int pop(){ if(last > 0){ int temp = a[last - 1]; a[last - 1] = 0; last = last – 1; return temp; } } void print(){ for(int i = 0; i < last; i++){ cout << a[i] << ” “; } } private: int a[5]; int jum; int last; }; int main(int argc, char *argv[]) { Stack x; x.push(2); x.push(4); x.push(11); x.push(5); x.push(7); x.push(9); x.push(30); x.print(); cout<<endl; x.pop(); x.pop(); x.pop(); x.pop(); //x.pop(); //x.pop(); x.print(); cout<<endl; system(“PAUSE”); return EXIT_SUCCESS; }...

TUGAS S-DATA ANTRIAN QUEUE

#include <cstdlib> #include <iostream.h> #define maks 5 //using namespace std; class Queue{ friend ostream& operator << (ostream&, const Queue&); //friend istream& operator >> (istream&, Queue&); public : Queue(); int penuh(int); int kosong(int); void cetak(); void enqueue(char); char dequeue(); private : int banyak; char A[maks]; }; ostream& operator << (ostream& out, const Queue& s) { cout <<”\nIsi Queue :”; for (int i=0; i<s.banyak; i++) out << s.A[i] << ” “; cout<<endl; } Queue::Queue(){ banyak = 0; for (int i=0; i<maks; i++) A[i]=’0′; } int Queue::penuh(int s) {return s==maks?1:0;} int Queue::kosong(int s) {return s==0?1:0;} void Queue::cetak() {cout <<”\nIsi dalam Queue sekarang  ...

Pages 51234 »

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More