#include <stdio.h> typedef struct STACK { int top; int list[3]; } stack; void create(stack *t) { t->top =-1; } int empty(stack *t) { if(t->top == -1) return (1); else return(0); } void push(stack *t) { int data; if (full(t) == 1) printf("\nStack is Full\n"); else { printf("\nPush Data : "); scanf("%d",&data); t->top++; t->list[t->top] = data; } } void pop(stack *t) { if(empty(t) == 1) printf("\nStack is Empty\n"); else t->top--; printf("\nStack is pop!\n"); } int full(stack *t) { if (t->top == 3) return (1); else return (0); } int main() { int select; stack t; create(&t); printf(" 1->Push \t\n 2->Pop \t\n 3->Exit\n Select :"); scanf("%d",&select); while(select!=3) { switch(select) { case 1: push(&t); break; case 2: pop(&t); break; default:break; } printf(" 1->Push \t\n 2->Pop \t\n 3->Exit\n Select :"); scanf("%d",&select); } return 0; }
Rabu, Mei 29, 2013
C : Array Stack (Push & Pop)
Label:
C/C++,
FSKTM,
Pengaturcaraan,
UTHM
Langgan:
Catat Ulasan (Atom)
0 ulasan:
Catat Ulasan
Selamat datang ke 0x2013LΣΣT. Sekiranya anda mempunyai persoalan, pandangan, permintaan, bantuan, cadangan dan sebagainya. Tinggalkan pesanan anda ke dalam kotak komen. Terima kasih !
- http://0x2013.blogspot.com -