Programming/자료구조&알고리즘
-
[자료구조] 기본 Queue 소스Programming/자료구조&알고리즘 2014. 3. 21. 18:29
큐 소스입니다. #include #include // 큐 크기 #define QSIZE(5) // 큐 선언 int queue[QSIZE]; int front, rear;// front == 0, rear == 0 int is_full() { return rear == QSIZE; } void put(int data) { queue[rear] = data; rear++; } int is_empty() { return front == rear; } int get() { int temp = queue[front]; front++; return temp; } // 큐 출력 void display() { int i; system("cls"); // 콘솔창 초기화 printf("\n"); printf("%*s\n"..
-
[자료구조] 기본 Stack 소스Programming/자료구조&알고리즘 2014. 3. 18. 03:14
스택 소스 입니다. #include #include // 스택 크기 #define STACK_MAX (5) // 스택 선언 int arr[STACK_MAX]; int top = -1; void push(int data) { arr[++top] = data; } int pop() {return arr[top--]; } int is_full() { return top == STACK_MAX-1; } int is_empty() { return top == -1; } // 스택 출력 void display() { int i; system("cls"); // 콘솔창 초기화 printf("\n"); for(i = 0; i top) printf("..