Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Queue.cpp
Package: tu.rar [view]
Upload User: gisslht
Upload Date: 2022-07-26
Package Size: 111k
Code Size: 1k
Category:
Graph program
Development Platform:
Visual C++
- #include "Queue.h"
- #include "tu.h"
- #include <iostream>
- using namespace std;
- int InitQueue( Queue &Q ) //初始化队列
- {
- Q.base = (ElemType *)malloc(Max_Vertex_Num*sizeof(ElemType));
- if ( !Q.base)
- exit(OVERFLOW); //分配失败
- Q.front = Q.rear = 0;
- return OK;
- }
- int EnQueue( Queue &Q, int e ) //入队
- {
- if( ( Q.rear + 1 ) % Max_Vertex_Num == Q.front )
- return ERROR; //队满
- Q.base[Q.rear] = e;
- Q.rear = ( Q.rear +1 ) % Max_Vertex_Num; //尾指针向后走一步
- return OK;
- }
- int DeQueue( Queue &Q, int &u ) //出队
- {
- int e;
- if( Q.front == Q.rear)
- return ERROR;
- else
- {
- e = Q.base[Q.front]; //将队中的队头元素(出队)赋给e
- Q.base[Q.front] = 0; //将队头元素的值赋值为0
- Q.front = ( Q.front + 1 ) % Max_Vertex_Num; //头指针向后走一步
- }
- u = e;
- return OK;
- }
- int QueueEmpty( Queue &Q ) //判断是否为空
- {
- if( Q.front == Q.rear )
- return ERROR;
- else
- return OK;
- }