#include <iostream> #include <stdlib.h> #define MAX 10 typedef struct { int Top; int Data[MAX]; typedef struct STACK{ int top; int Data[MAX]; }; typedef struct Stack CreateStack (Stack *S); typedef struct { Stack *S; Stack *S.Top = -1; return *S.Top ; } IsFull(Stack *S) { if (S.TOP == (MAX -1)) return 1; else return 0; } IsEmpty(Stack *S) { if (S.TOP == -1) return 1; else return 0; } Push(Stack *S, int X) { if (IsFULL(*S)) printf(" Stack Penuh "); else (Stack *S).Top++; (Stack *S).Data[(Stack *S).TOP] = X; } Pop(Stack *S) { int X; if (IsEmpty(*S)) { printf(" \nStack Tidak Bisa Di POP !" ) X = -99999l ; } else { X = (*S).Data[(*S).TOP]; (*S).TOP--; } return X; } int main() { Stack S1; S1 = CreateStack(); if (IsEmpty(S1)); printf( "Stack Kosong" ); else printf( "Stack Isi !" ); Push(&S1,2); system("PAUSE"); return 0; }; } |