큐를 구현하시오(배열, 환형큐, 연결리스트)
본 자료는 2페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

큐를 구현하시오(배열, 환형큐, 연결리스트)에 대한 보고서 자료입니다.

목차

없음

본문내용

clude < stdio.h >
#include < string.h >
#include
struct queue {
char data;
struct queue *next;
};
struct queue *head;
int addq(char n)
{
struct queue *q, *tmp;
q = (struct queue*)malloc(sizeof(struct queue));
if( !q ) {
printf("memory allocation error\n");
}
q->data = n;
q->next = NULL;
if( head == NULL ) {
head = q;
} else {
tmp = head;
while( tmp->next ) tmp = tmp->next;
tmp->next = q;
}
return 0;
}
struct queue *deleteq()
{
struct queue *q;
q = head;
head = head->next;
return q;
}
void ShowQ()
{
struct queue *q = head;
printf("QUEUE : ");
if( q == NULL )
printf("queue empty");
else{
while( q ) {
printf("%c",q->data);
if( q->next ) printf(" ");
q = q->next;
}
}
printf("\n");
}
void main()
{
struct queue *q;
ShowQ();
printf("In A\n");
addq('A');
ShowQ();
printf("In B\n");
addq('B');
ShowQ();
printf("Out\n");
q = deleteq(); free(q);
ShowQ();
printf("Out\n");
q = deleteq(); free(q);
ShowQ();
printf("Out\n");
q = deleteq(); free(q);
ShowQ();
printf("In C\n");
addq('C');
ShowQ();
printf("In D\n");
addq('D');
ShowQ();
printf("In E \n");
addq('E');
ShowQ();
printf("In F\n");
addq('F');
ShowQ();
printf("In G\n");
addq('G');
ShowQ();
printf("In H\n");
addq('H');
ShowQ();
}

키워드

  • 가격1,300
  • 페이지수6페이지
  • 등록일2006.02.28
  • 저작시기2005.12
  • 파일형식한글(hwp)
  • 자료번호#325601
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니