排队多条线 [英] Queues for more than one Line

查看:90
本文介绍了排队多条线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要3条线,请给他们帮助.

这是输出示例:
1:00:11 pm:客户ANGEL在A行中进行检查.
1:01:36 pm:第1行中的客户ANGEL等待了85秒.

所以时间:客户名称在第x行中检查.

我应该像这样制作3个队列指针吗?:

Hi, I need to have 3 lines and I need help with them please.

This is example of the output:
1:00:11pm: Customer ANGEL checking in line A.
1:01:36pm: Customer ANGEL checking out of line 1 waited 85 seconds.

so TIME: Customer NAME checking in line x.

Should I make 3 queue pointers like this?:

struct queue* LineA;
struct queue* LineB;
struct queue* LineC;

LineA = (struct queue*)malloc(sizeof(struct queue));
LineB = (struct queue*)malloc(sizeof(struct queue));
LineC = (struct queue*)malloc(sizeof(struct queue));



还是只有一个指针并以某种其他方式具有3行功能?

因为我在如何打印时遇到麻烦.如果我创建了一个名为lines的函数,我想我可以在主体中打印如下内容:
//printf("TIME:客户%s检入%s \ n行",名称,行(QueuePtr));
并且我将在函数或main
中使用if语句 我还没有弄清楚如何做时间.
像我如何说在A行中检查?

因此,如果我确实创建了一个名为lines的函数,那么对于每一行,它应该只有一个参数还是3个?

这些是我现在拥有的功能:



or only have one pointer and have 3 lines some other way with a function?

Because I was having trouble with how to print it. If I make a function called lines, I was thinking I could print in main something like this:
//printf("TIME: Customer %s checking in line %s\n", name, lines(QueuePtr));
and I would be using if statements in the function or in main
I haven''t sorted out how to do the time yet.
like How would I get it to say checking in line A?

So if I do make a function called lines, should it have only one parameter or 3 for each of the lines?

These are the functions I have right now:

//I have them, but I just declared them here.
void initial_queue(struct queue* p);
int enqueue(struct queue* p, int value);
int dequeue(struct queue* p);
int empty(struct queue* p);
int front(struct queue* p);



顺便说一下,有一个输入文件.

也许有人可以帮我弄清楚在使用带有链接列表的队列时如何打印多个队列.

哦,这是我的结构:



There is an input file by the way.

Maybe someone could just please help me figure out how to print several queues when using queues with a linked list.

Oh and this is my struct:

// Stores node of the linked list.
struct node {
    int data;
    struct node* next;
};
// Stores our queue.
struct queue {
    struct node* front;
    struct node* rear;
};



好吧,我知道printf语句可以在main中并且可以使用line函数,但是我不太确定如何将linef或hwo的时间设置为HH:MM:SSpm格式.



Ok, I know the printf statements can be in main and a line function can be used, but I''m not really sure how to do the line function or hwo to have the time in the format HH:MM:SSpm.

推荐答案

我不太清楚这个问题.
看起来您正在从输入文件中获取一些数据并进行打印.正确吗?
您应该考虑使用诸如std::queue的标准容器.
I don''t quite understand the question properly.
Looks like you''re taking some data from an input file and printing something. Is that correct?
You should consider using standard containers like std::queue.


这篇关于排队多条线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆