以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  金字塔软件问题提交  (http://222.73.7.161/bbs/list.asp?boardid=2)
----  [原创]如何创建一个队列?  (http://222.73.7.161/bbs/dispbbs.asp?boardid=2&id=74286)

--  作者:guguqiaqia
--  发布时间:2015/1/12 9:24:25
--  [原创]如何创建一个队列?
如何像如下c那样创建队列,有现成的算法和函数没有 ?

#define debug 1
#define MaxN 1024

struct queue {
int q[MaxN];
int front;
int rear;

// initial the queue
void initial() {
front = 0;
rear = 0;
memset(q, 0, sizeof(q));
}
// judge wether the queue is empty or not
bool empty() {
return front == rear;
}
// insert an element
void push(int x) {
if (rear == MaxN) {
printf("The queue is fool !\\n");
}
q[rear] = x;
++rear;
}
// delete an element
void pop() {
if (empty()) {
printf("There is no element in the queue !\\n");
}
++front;
}
// look up the first element
int top() {
if (empty()) {
printf("There is no element in the queue !\\n");
}
return q[front];
}
};

--  作者:yukizzc
--  发布时间:2015/1/12 9:43:45
--  

意思要求下单按队列去报?

看下ORDERQUEUE函数


--  作者:guguqiaqia
--  发布时间:2015/1/12 9:45:40
--  
以下是引用yukizzc在2015/1/12 9:43:45的发言:

意思要求下单按队列去报?

看下ORDERQUEUE函数

不是那么简单。 要么我自己用数组研究实现吧。