티스토리 뷰
#include<stdio.h>
#define MAX 10
int front,rear;
char queue[MAX];
void init_queue()
{
front = rear = 0;
}
void clear_queue()
{
front = rear;
}
int put(char* ch)
{
if( (rear+1)%MAX == front )
return -1;
queue[rear] = *ch;
rear = ++rear % MAX;
return 0;
}
int get(char* ch)
{
if( rear == front )
return -1;
*ch = queue[front];
front = ++front % MAX;
return 0;
}
void main()
{
char a,b,c;
init_queue();
put("1");
put("2");
put("4");
printf("%c%c%c%c\n",queue[0],queue[1],queue[2],queue[3]);
get(&a);
get(&b);
get(&c);
printf("%c%c%c%\n",a,b,c);
}
'프로그래밍 언어 > 프로그래밍' 카테고리의 다른 글
트리 (0) | 2009.01.18 |
---|---|
연결 리스트 (문장<이름>) (0) | 2009.01.18 |
연결 리스트 (한 글자) (0) | 2009.01.18 |
퀵정렬 (0) | 2009.01.18 |
스택 (0) | 2009.01.17 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 청년정책
- 김광석 기타 코드
- 유니티
- 신청
- 임창정
- 축제
- 김광석
- 아이유
- 공연
- 버즈
- 안드로이드
- 청년
- 공모전
- 유머
- 민경훈
- 서울시
- 뜻밖의 샤워
- 서울특별시
- 고양이 깜놀
- 김광석 코드
- 태풍발생
- 발생후
- 지원금
- 지원
- 혁오
- android
- 연결 리스트
- 문화
- 청년몽땅정보통
- Linked List
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함