Oneself write operation and output the same but OJ has been not to please everyone a great god to help us see what is wrong with
Here are several commands and the meaning of the queue:
INIT initialization queue The PRINT output one line: from the beginning to the end output queue each element, element are separated with a space ENTER the value value into the team OUT if the queue is not empty, the team first element OUT of the team, if the queue is empty, do not do any action, LENGTH the number of elements in the output current queue
Queue is the character of each element,
Input The test cases of the first line is an integer n (0 & lt; N & lt; 10000), said the test case of how many command,
Followed by n lines, each line is a command, sequentially from beginning to end each command,
The Output PRINT and LENGTH of them command, output the corresponding information,
The Sample Input 11. INIT ENTER E ENTER 5 ENTER t LENGTH ENTER 8 ENTER A PRINT the OUT LENGTH PRINT the
The Sample Output 3 E 5 t 8 A 4 8 A 5 t
Here is my code: #include #include # include # include # include # include using namespace std; # define OK 1 # define the ERROR 0 # define OVERFLOW - 2
Typedef char QElemType; Typedef struct { QElemType * base;//storage base address Int the front;//the head pointer Int rear;//the tail pointer
Int main () { SqQueue Q; int i=0; Char value; Int choice; Char s [10]; The scanf (" % d ", & amp; Choice); While (i{
scanf("%s",s); If (STRCMP (" INIT ", s)==0) INIT (Q);
Else if (STRCMP (" ENTER ", s)==0) { The scanf (" % s ", & amp; Value); ENTER (Q value); }
Else if (STRCMP (" PRINT ", s)==0) PRINT (Q);
Else if (STRCMP (" LENGTH ", s)==0) printf (" % d \ n ", LENGTH (Q));
Else if (STRCMP (" OUT ", s)==0) OUT (Q value);
i++;
} Free (Q.b ase);
return 0; }
CodePudding user response:
Abnormal considering imperfect, you take a queue when a ring to deal with, Assuming that full of 10000 data, bring up a, into another, your rear++ not cross a line?
So every function to consider more, considering the rear reverse!