Home > Back-end >  C language in three sorted array in order in the queue, asked the great spirit guide
C language in three sorted array in order in the queue, asked the great spirit guide

Time:10-04

#include
using namespace std;
# define OK 1
# define the ERROR 0
# define OVERFLOW - 2
# define MAXSIZE 10
Typedef int the status;
Typedef int Qelemtype;
Typedef struct {
Qelemtype * base;
Int the front;
Int rear;
} squene;
The status lnitquene (squene & amp; Q);
The status Enquene (squene & amp; Q, Qelemtype & amp; E);
The status Dequene (squene & amp; Q, Qelemtype & amp; E);
Int length (squene Q);
Void the insert ();
Int main ()
{squene list;
Insert ()
return 0;
}
The status lnitquene (squene & amp; Q)
{
Q.b ase=new Qelemtype [MAXSIZE];
if(! Q.b ase) exit (OVERFLOW);
Q.f ront=Q.r ear=0;
return OK;
}
The status Enquene (squene & amp; Q, Qelemtype & amp; E)
{if ((Q.r ear + 1) % MAXSIZE==Q.f ront) return the ERROR;
Q.b ase [Q.r ear]=e;
Q.r ear=(Q.r ear + 1) % MAXSIZE;
return OK;
}
The status Dequene (squene & amp; Q, Qelemtype & amp; E)
{if (Q.f ront==Q.r ear) return the ERROR;
E=Q.b ase [Q.f ront];
Q.f ront=(Q.f ront + 1) % MAXSIZE;
return OK;
}
Int length (squene Q) {
Return (Q.r ear - Q.f ront + MAXSIZE) % MAXSIZE;
}
Void the insert () {
Squene list;
Int a [3]={1, 2, 3};
Int [3] b={4 and 6};
Int [3] c={7,8,9};
Int I=0, j=0, k=0;

While (i<=3 | | j<=3 | | k
=3){
If (a [I] <=b [j] <=c [k]) {i++; Enquene (list, a [I]); }
Else if (b [I] <=a [j] <=c [k]) {j++; Enquene (list, and b [j]); }
The else {i++; Enquene (list, [k] c); }
}

CodePudding user response:

How do you say?
Or that sentence, first to learn grammar well, otherwise the problems will be more and more

CodePudding user response:

Inside the main function to initialize the queue
Then to insert again, inert and well know where is also required in a queue interpolation
Insert inside the if judgment without a< also; B
Basic grammar well
This code is copied to a queue, then don't understand how to use start with
Go cram basis, otherwise change also makes no sense, so why don't know right or wrong
  • Related