ProgramCodeCompilation is successful and no runtime test is performed.
/* This program tests the Linear Logic Structure: queue */ # Include <Stdio. h> # Include <Stdlib. h> Struct Queuelist { Int * Queue; Int Front; Int Rear; Int Size ;}; typedef Struct Queuelist queue; typedef Enum {False, true} bool; Void Createqueue (queue * queue, Int Size); bool isqueueempty (queue * Queue); bool isqueuefull (queue * Queue); bool enqueue (queue * Queue, Int Element); bool dequeue (queue * Queue,Int * Element ); Int Main ( Int Argc, Char * Argv []) {queue; createqueue ( & Queue, 10 ); If (Isqueueempty (& Queue) puts ( " Empty queue. \ n " ); Getchar (); Return 0 ;} /* Function: Create a queue function prototype: void createqueue (queue * queue, int size) function parameter: queue * queue: pointer int size of the queue to be created: size of the queue to be created return value: no exception: Pass pointer */ Void Createqueue (queue * queue, Int Size ){ If (Queue! = NULL & size> 0 ){ If (Queue-> queue = (Int *) Malloc (size + 1 )* Sizeof ( Int ) {Queue -> Front = Size; queue -> Rear = Size; queue -> Size = Size ;} Else {Puts ( " Error. \ n " ); Exit ( 0 );}} Else {Puts ( " Error. \ n " ); Exit ( 0 );}} /* Function: determines whether the queue is empty. The function prototype is bool isqueueempty (queue * Queue). function parameter: queue * queue: The returned value of the queue pointer to be judged. If it is null, true is returned, otherwise, a false exception is returned. a null pointer is passed. */ Bool isqueueempty (queue * Queue ){ If (Queue & queue-> Queue ){ If (Queue-> front = queue-> Rear ){ Return True ;} Else { Return False ;}} Else {Puts ( " Error. \ n " ); Exit ( 0 );}} /* Function: determines whether the queue is full. function prototype: bool isqueuefull (queue * Queue) function parameter: queue * queue: queue pointer returned value: true if the queue is full, otherwise, a false exception is returned. a null pointer is passed. */ Bool isqueuefull (queue * Queue ){ If (Queue & queue->Queue ){ If (Queue-> rear = 0 ){ Return True ;} Else { Return False ;}} Else {Puts ( " Error. \ n " ); Exit ( 0 );}} /* Function: the prototype of the inbound function: bool enqueue (queue * queue, int element) function parameter: queue * queue: queue pointer to be queued int element: Elements to be queued */ Bool enqueue (queue * Queue, Int Element ){ If (Null = queue | null = queue-> Queue) {puts ( " Error. \ n " ); Exit ( 0 );} // If the queue is empty If (Isqueueempty (Queue )){ If (Queue-> front = 0 ){ // Left blank after calculation Queue-> front = queue-> Size; queue -> Queue [queue-> front] = Element; Return True ;} Else { // The queue is empty in the initialization status. Queue-> queue [queue-> front] = Element; queue -> Rear -- ; Return True ;}} Else { If (Isqueuefull (Queue )){ Return False;} queue -> Queue [queue-> rear] = Element; queue -> Rear -- ; Return True ;}} /* Function: Departure function prototype: bool dequeue (queue * queue, int * element) function parameter: queue * queue, the returned value of the element value is stored. True is returned if the team is successfully displayed. False is returned if the team fails and * element = 0 is set; */ Bool dequeue (queue * Queue, Int *Element ){ If (Null = queue | null = queue-> queue | null = Element) {puts ( " Error. \ n " ); Exit ( 0 );} If (Isqueueempty (Queue )){ // The queue is empty. * Element = 0 ; Return False ;} Else { // The queue is not empty. * Element = queue-> queue [queue-> Front]; queue -> Front -- ; Return True ;}}