qtype.cpp

来自「此文件可以能帮你求体积」· C++ 代码 · 共 47 行

CPP
47
字号
// QType.cpp: implementation of the QType class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "QType.h"
#include <iostream.h>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

QType::QType()
: head(0), tail(0)
{

}

QType::~QType()
{

}

int QType::Fetch()
{
	if (head == tail)
	{
		cout << "Queue is empty\n";
		return 0;
	}

	head = (head+1)%SIZE;
	return queue[head];
}

void QType::Store(int num)
{
	if ( (tail+1) % SIZE == head )
	{
		cout << "Queue is full\n";
		return;
	}

	tail = (tail+1)%SIZE;
	queue[tail] = num;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?