U E D R , A S I H C RSS

Stack/임다찬

~cpp
#include <stdio.h>
int array[10]={0,};
int index=0,top=9,bottom=0;
int empty(){
	return index==bottom;
}
int full(){
	return index==top;	
}
void push(int data){
	if(full()){
		printf("FULL\n");
	}
	else{
		array[index++]=data;		
	}
}
int pop(){
	int pop_number;
	if(empty()){
		printf("EMPTY\n");
	}
	else{	
		pop_number=array[index];
		array[index--]=0;
		return pop_number;
	}
}
void print(){
	int i;
	for(i=0;i<index;i++){
			printf("%d ",array[i]);
		}
	printf("\n");

}
int main(void){
	pop();
	push(3);
	push(4);
	push(5);
	push(9);
	push(3);
	push(4);
	push(5);
	push(9);
	push(3);
	push(4);
	push(5);
	push(9);
	print();
	pop();
	pop();
	pop();
	pop();



	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0864 sec