Я выкладываю весь код здесь. Я получаю сообщение об ошибке " remove", определение переопределено, различные базовые типы. Существует четыре очереди, которые реализованы с использованием связанных списков, и функция remove должна занятьочередь и вспомогательная переменная, которая используется для временного хранения информации об узле в качестве параметров.
#include<stdio.h>
#include<stdlib.h>
#define NULL 0
#define TRUE 1
#define FALSE 0
struct node
{
int duration,time,type;
struct node* next;
};
typedef struct node* NODEPTR;
struct queue {
NODEPTR front, rear;
int num;
};
struct queue q[4];
struct node auxinfo;
NODEPTR evlist;
int atime, dtime, dur, qindx;
float count, tottime;
void place(NODEPTR*,struct node *);
void popsub(NODEPTR*, struct node*);
void arrive(int, int);
void depart(int, int);
void push(NODEPTR*, struct node*);
void insafter(NODEPTR*, struct node*);
int empty(NODEPTR);
void insert(struct queue*, struct node);
void remove(struct queue*, struct node);
NODEPTR getnode(void);
void freenode(NODEPTR);
int main()
{
evlist = NULL;
count = 0;
tottime = 0;
for (qindx = 0; qindx < 4; qindx++) {
q[qindx].num = 0;
q[qindx].front = NULL;
q[qindx].rear = NULL;
}
printf("enter time and duration\n");
scanf_s("%d %d", &auxinfo.time, &auxinfo.duration);
auxinfo.type = -1;
place(&evlist, &auxinfo);
while (evlist != NULL) {
popsub(&evlist, &auxinfo);
if (auxinfo.type == -1) {
atime = auxinfo.time;
dur = auxinfo.duration;
arrive(atime, dur);
}
else {
qindx = auxinfo.type;
dtime = auxinfo.time;
depart(qindx, dtime);
}
}
}
NODEPTR getnode(void)
{
NODEPTR p;
p = (NODEPTR)malloc(sizeof(struct node));
return(p);
}
void freenode(NODEPTR evlist)
{
free(evlist);
}
int empty(NODEPTR evlist)
{
return((evlist == NULL) ? TRUE : FALSE);
}
void push(NODEPTR *evlist , struct node *auxinfo)
{
NODEPTR p;
p = getnode();
p->duration = auxinfo->duration;
p->time = auxinfo->time;
p->type = auxinfo->type;
p->next = *evlist;
*evlist = p;
}
void insafter (NODEPTR* evlist, struct node* auxinfo)
{
NODEPTR p,q;
p = *evlist;
if (p == NULL) {
printf("void insertion\n");
exit(1);
}
q = getnode();
q->duration = auxinfo->duration;
q->time = auxinfo->time;
q->type = auxinfo->type;
q->next = p->next;
p->next = q;
}
void place(NODEPTR* evlist, struct node* auxinfo)
{
NODEPTR p, q;
q = NULL;
for (p = *evlist; p != NULL && auxinfo->time > p->time; p = p->next)
q = p;
if (q = NULL)
push(evlist, auxinfo);
else
insafter(q, auxinfo);
}
void popsub(NODEPTR* evlist, struct node* auxinfo)
{
NODEPTR temp, q;
q = *evlist;
if (empty(q))
{
printf("underflow");
exit(1);
}
else {
temp = q;
q = q->next;
auxinfo = temp;
free(temp);
}
}
void insert(struct queue *q, struct node auxinfo)
{
//int j;
NODEPTR p;
p = getnode();
p->duration = auxinfo.duration;
p->time = auxinfo.time;
p->type = auxinfo.type;
p->next = NULL;
if (q->rear == NULL)
q->front = p;
else
q->rear->next = p;
q->rear = p;
q->num = q->num + 1;
}
void remove(struct queue *q, struct node auxinfo)
{
//int qindx;
NODEPTR p;
if (q->front == NULL) {
printf("queue underflow\n");
exit(1);
}
p = q->front;
auxinfo.duration = p->duration;
auxinfo.time = p->time;
auxinfo.type = p->type;
q->front = p->next;
if (q->front == NULL)
q->rear = NULL;
freenode(p);
q->num = q->num - 1;
}
void arrive(int atime, int dur)
{
int i, j, small;
j = 0;
small = q[0].num;
for(i=1;i<4;i++)
if (q[i].num < small) {
small = q[i].num;
j = i;
}
auxinfo.time = atime;
auxinfo.duration = dur;
auxinfo.type = j;
insert(&q[j], auxinfo);
if (q[j].num == 1) {
auxinfo.time = atime + dur;
place(&evlist, &auxinfo);
}
printf("enter time\n");
if (scanf_s("%d", &auxinfo.time) != EOF) {
printf("enter duration\n");
scanf_s("%d", &auxinfo.duration);
auxinfo.type = -1;
}
}
void depart(int qindx, int dtime)
{
NODEPTR p;
remove(&q[qindx], auxinfo);
tottime = tottime + (dtime - auxinfo.time);
count++;
if (q[qindx].num > 0) {
p = q[qindx].front;
auxinfo.time = dtime + p->duration;
auxinfo.type = qindx;
place(&evlist, &auxinfo);
}
}