티스토리 뷰
Queue.h
// Queue.h: interface for the CQueue class.
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_QUEUE_H__53C50204_BCF9_45DF_8A69_7BA4AC7AB4FD__INCLUDED_)
#define AFX_QUEUE_H__53C50204_BCF9_45DF_8A69_7BA4AC7AB4FD__INCLUDED_
#define AFX_QUEUE_H__53C50204_BCF9_45DF_8A69_7BA4AC7AB4FD__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define MAXQ 10
#define EMPTY -98384
#define EMPTY -98384
class CQueue
{
public:
CQueue();
virtual ~CQueue();
{
public:
CQueue();
virtual ~CQueue();
int Enque(int nData);
int Deque();
int Deque();
private:
int m_Queue[MAXQ];
int m_nFront,
int m_Queue[MAXQ];
int m_nFront,
m_nBack;
};
};
#endif // !defined(AFX_QUEUE_H__53C50204_BCF9_45DF_8A69_7BA4AC7AB4FD__INCLUDED_)
Queue.cpp
// Queue.cpp: implementation of the CQueue class.
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
#include"Queue.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CQueue::CQueue()
{
m_nFront = 0;
m_nBack = 0;
}
{
m_nFront = 0;
m_nBack = 0;
}
CQueue::~CQueue()
{
{
}
int CQueue::Enque(int nData)
{
if(m_nBack == (m_nFront - 1))
return false;
{
if(m_nBack == (m_nFront - 1))
return false;
m_Queue[m_nBack] = nData;
++m_nBack;
++m_nBack;
if(m_nBack >= MAXQ)
m_nBack = 0;
m_nBack = 0;
return true;
}
}
int CQueue::Deque()
{
if(m_nFront+1 == m_nBack)
return EMPTY;
{
if(m_nFront+1 == m_nBack)
return EMPTY;
int nTemp = m_Queue[m_nFront];
++m_nFront;
++m_nFront;
if(m_nFront >= MAXQ)
m_nFront = 0;
m_nFront = 0;
return nTemp;
}
}
main.cpp
#include <stdio.h>
#include "Queue.h"
#include "Queue.h"
void main()
{
CQueue Queue;
int nData = 0,
nErr;
{
CQueue Queue;
int nData = 0,
nErr;
for(int i=0; i<MAXQ; ++i)
{
nErr = Queue.Enque(i);
if(!nErr)
break;
{
nErr = Queue.Enque(i);
if(!nErr)
break;
printf("Enque(%d)\n", i);
}
}
for(i=0; i<MAXQ; ++i)
{
nData = Queue.Deque();
if(nData == EMPTY)
break;
{
nData = Queue.Deque();
if(nData == EMPTY)
break;
printf("Deque(%d)\n", nData);
}
}
}
}
Result
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 겨울
- 오라클
- CNN Student News
- 티스토리달력2010
- 동유럽
- 젤다의 전설
- 스포어
- Free Coupon
- ndsl
- 웃기는 사진
- 가을
- DLC
- 야생의 숨결
- 슈퍼마리오 RPG
- Wii GAME
- Spore
- NDS GAME LIST
- C/C++
- NDSi
- Project Diet
- 동물의숲
- 아이폰
- jsp
- oracle
- 군대이야기
- 티스토리달력2011
- 3분 영어 위클리
- NDS
- 게시판
- 2011사진공모전
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함