NTSTATUS VIOSerialShutDownAllQueues( IN WDFOBJECT WdfDevice, IN BOOLEAN bFinal) { NTSTATUS status = STATUS_SUCCESS; PPORTS_DEVICE pContext = GetPortsDevice(WdfDevice); UINT nr_ports, i; TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "--> %s\n", __FUNCTION__); VirtIODeviceRemoveStatus(pContext->pIODevice , VIRTIO_CONFIG_S_DRIVER_OK); if(pContext->isHostMultiport) { DeleteQueue(&pContext->c_ivq, bFinal); DeleteQueue(&pContext->c_ovq, bFinal); } nr_ports = pContext->consoleConfig.max_nr_ports; for(i = 0; i < nr_ports; i++ ) { if(pContext->in_vqs && pContext->in_vqs[i]) { DeleteQueue(&(pContext->in_vqs[i]), bFinal); } if(pContext->out_vqs && pContext->out_vqs[i]) { DeleteQueue(&(pContext->out_vqs[i]), bFinal); } } TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "<-- %s\n", __FUNCTION__); return status; }
int main() { FILE *ptr; ptr=fopen("file.txt","r"); CheckFileForError(ptr); CreateQueue(); char str[80]; int i, pnum, atime,btime; while(fgets(str,80,ptr)!=NULL) { int *point; point = FindNuminString(str,0); pnum = *point; point = FindNuminString(str,*(point+1)); atime = *point; point = FindNuminString(str,*(point+1)); btime = *point; EnQueue(pnum,atime,btime); } CalculatePSJF(); fclose(ptr); DeleteQueue(); return 0; }
static bool JustMoveLabel( common_info *max, ins_entry *ins ) /***************************************************************/ { oc_class cl; ins_entry *lbl; ins_entry *add; ins_entry *next; optbegin if( PrevClass( max->start_del ) != OC_LABEL ) optreturn( FALSE ); lbl = PrevIns( max->start_del ); if( _Attr( lbl ) & ATTR_SHORT ) optreturn( FALSE ); cl = PrevClass( lbl ); if( !_TransferClass( cl ) ) optreturn( FALSE ); DeleteQueue( lbl ); InsertQueue( lbl, PrevIns( max->start_com ) ); add = PrevIns( max->start_del ); for( ;; ) { next = NextIns( add ); DelInstr( next ); if( next == ins ) { break; } } Untangle( lbl ); optreturn( TRUE ); }
int main() { FILE *ptr; ptr=fopen("file.txt","r"); CheckFileForError(ptr); CreateQueue(); char str[80]; int i, pnum, atime,btime; while(fgets(str,80,ptr)!=NULL) { int *point; point = FindNuminString(str,0); pnum = *point; point = FindNuminString(str,*(point+1)); atime = *point; point = FindNuminString(str,*(point+1)); btime = *point; EnQueue(pnum,atime,btime); } int time_quantum; printf("\n Enter the time quantum: "); scanf("%d",&time_quantum); CalculateRR(time_quantum); fclose(ptr); DeleteQueue(); return 0; }
static void TransformJumps( ins_entry *ins, ins_entry *first ) /****************************************************************/ { ins_entry *add; ins_entry *next; ins_entry *lbl; oc_class cl; optbegin if( _Class( ins ) == OC_RET ) optreturnvoid; lbl = _Label( ins )->ins; if( lbl == NULL ) optreturnvoid; add = lbl; for( ;; ) { if( add == NULL ) optreturnvoid; cl = _Class( add ); if( _TransferClass( cl ) ) break; if( cl == OC_LABEL ) { if( _Attr( add ) & ATTR_SHORT ) optreturnvoid; _ClrStatus( _Label( add ), SHORTREACH ); } add = NextIns( add ); } if( add == first || add == ins ) optreturnvoid; if( FindShort( first, lbl ) ) optreturnvoid; for( ;; ) { next = PrevIns( add ); DeleteQueue( add ); InsertQueue( add, first ); if( add == lbl ) break; add = next; } DeleteQueue( first ); InsertQueue( first, next ); Untangle( NextIns( first ) ); optend }
void DeinitPathFinder(PathFinder* pathFinder) { DeleteQueue(pathFinder->openList); for (int i = 0; i < pathFinder->map->width; ++i) free(pathFinder->nodeMap[i]); free(pathFinder->nodeMap); DeletePath(pathFinder); }
void printtopsortorder(graph g) { Queue q; ptrtoedge tempedge; int *degree; int count,count2,tempint; q = NewQueue(); printf("\n"); /*set up the degree array*/ degree = malloc(sizeof(int)*g->numvertices); if(degree == NULL) FatalError("\nout of memory"); for(count=0;count<g->numvertices;count++) degree[count] = 0; for(count = 0;count<g->numvertices;count++) { tempedge = g->array[count]; while(tempedge != NULL) { degree[tempedge->vertex]++; tempedge = tempedge->next; } } /*sort and print out the sorted vertices*/ count2 = g->numvertices; while(count2 != 0) { /*get vertices to print out this time around*/ for(count=0;count<g->numvertices;count++) { if(degree[count] == 0) { Enqueue(count,q); } } /*in case of a cycle exit wiht error*/ if(IsEmptyQueue(q)) FatalError("There is a cycle involving the remaining vertices."); /*adjust degree for the removed vertices and print out the vertex*/ while(!IsEmptyQueue(q)) { count2--; tempint = Dequeue(q); printf("%d ",tempint); degree[tempint] = -1; tempedge = g->array[tempint]; while(tempedge != NULL) { degree[tempedge->vertex] -= 1; tempedge = tempedge->next; } } } DeleteQueue(q); }
int main(void) { Stack s1; Stack s2; s1 = CreateStack(10); s2 = CreateStack(10); Item it = 1; AddQueue(it, s1,s2); it = 2; AddQueue(it,s1,s2); it = 3; AddQueue(it,s1,s2); DeleteQueue(&it,s1,s2); printf("%d\n",it); DeleteQueue(&it,s1,s2); printf("%d\n",it); DeleteQueue(&it,s1,s2); printf("%d\n",it); }
/*server engine start function */ int main(int argc,char *argv[]) { char * Ip_Addr = NULL; char * sPort; char * tmpptr; char * ServerId = NULL; int Port; ServerId = argv[1]; int new_fd,i,j,thread_no; debug_print(("Server Engine Open!\n")); /*初始化任务队列*/ p = (tQueue *)malloc(sizeof(struct Queue)); InitQueue(p); /*创建MAX_THREADNUM个线程,并初始化该线程对应的信号量*/ for(i = 0;i < MAX_THREADNUM ; i++) { thread_no = i; sem_init(&pSems[i],0,0); //初始化线程信号量 if(pthread_create(&thread_id[i] ,NULL,(void*)AllocateTask,(void*)thread_no) != 0) { fprintf(stderr,"pthread_create Error,%s:%d\n",__FILE__,__LINE__); exit(-1); } } ServerPrepare(ServerId); printf("server engine open!\n"); pthread_mutex_init(&mutex, NULL); while(1) { new_fd = ServerOpen(); ptask = (tQueueNode *)malloc(sizeof(struct QueueNode)); ptask->sockfd = new_fd; tmpptr = RecvData(new_fd); memcpy(ptask->pBuf,tmpptr,strlen(tmpptr)+1); ptask->bufsize = strlen(ptask->pBuf); debug_print(("ptask you want insert:sockfd is %d,pBuf is %s,bufsize is %d\n",ptask->sockfd,\ ptask->pBuf,\ ptask->bufsize)); InQueue(p,ptask); //如果收到数据则入队等候处理 j = (rand()%3); //随机唤醒其中的一个线程将资源分配给该线程 debug_print(("V op +%d thread\n",j)); sem_post(&pSems[j]); //用信号量v操作将资源数目+1 } ServerCloseinfo(ServerId); CloseServer(); for(i = 0;i < MAX_THREADNUM;i++) { sem_destroy(&pSems[i]); DeleteQueue(p); } return 0; }
void InsertInBinaryTree(struct BinaryTreeNode *root, int insertData) { struct BinaryTreeNode *temp; struct BinaryTreeNode *insertNode; struct DynArrayQueue *Q = CreateQueue(); insertNode = (struct BinaryTreeNode *)malloc(sizeof(struct BinaryTreeNode)); if(!insertData) { printf("Memory Error!\n"); return; } insertNode->data = insertData; insertNode->left = NULL; insertNode->right = NULL; if (!root) { printf("!root!\n"); root = insertNode; return; } EnQueue(Q, root); while (!IsEmptyQueue(Q)) { temp = DeQueue(Q); if (temp->left) { EnQueue(Q, temp->left); } else { temp->left = insertNode; printf("%d insert into left of %d\n", insertNode->data, temp->data); DeleteQueue(Q); return; } if (temp->right) { EnQueue(Q, temp->right); } else { temp->right = insertNode; printf("%d insert into right of %d\n", insertNode->data, temp->data); DeleteQueue(Q); return; } } DeleteQueue(Q); }
// right - left >= 0 ---> 1, otherwise 0 // down - top >= 0 ---> 1, otherwise 0 void CompactColor(unsigned char *CompactValue, double *HistogramValue) { qdata *pop, Queue[NUM_BINS]; int qfront = 0, qrear = 0; int width = 8; // 8x8 = 64 int i, j, jj, count; double left, right; AddQueue(Queue, &qrear, 0, 0, 8, 8, 0); count = 0; while( (pop=DeleteQueue(Queue, &qfront, qrear)) ) { left = right = 0; // left also denote top, right also denote down if( pop->flag == 0 ) // right - left { for(j=pop->posY, jj=pop->posY*width; j<pop->posY+pop->sizeY; j++, jj+=width) for(i=pop->posX; i<pop->posX+pop->sizeX/2; i++) left += HistogramValue[jj+i]; for(j=pop->posY, jj=pop->posY*width; j<pop->posY+pop->sizeY; j++, jj+=width) for(i=pop->posX+pop->sizeX/2; i<pop->posX+pop->sizeX; i++) right += HistogramValue[jj+i]; } else // down - top { for(j=pop->posY, jj=pop->posY*width; j<pop->posY+pop->sizeY/2; j++, jj+=width) for(i=pop->posX; i<pop->posX+pop->sizeX; i++) left += HistogramValue[jj+i]; for(j=pop->posY+pop->sizeY/2, jj=(pop->posY+pop->sizeY/2)*width; j<pop->posY+pop->sizeY; j++, jj+=width) for(i=pop->posX; i<pop->posX+pop->sizeX; i++) right += HistogramValue[jj+i]; } CompactValue[count] = (right>left) ? 1 : 0; count ++; // push into queue if( pop->flag == 0 && pop->sizeX > 1 ) { AddQueue(Queue, &qrear, pop->posX, pop->posY, pop->sizeX/2, pop->sizeY, 1); AddQueue(Queue, &qrear, pop->posX+pop->sizeX/2, pop->posY, pop->sizeX/2, pop->sizeY, 1); } else if( pop->flag == 1 && pop->sizeY > 2 ) { AddQueue(Queue, &qrear, pop->posX, pop->posY, pop->sizeX, pop->sizeY/2, 0); AddQueue(Queue, &qrear, pop->posX, pop->posY+pop->sizeY/2, pop->sizeX, pop->sizeY/2, 0); } } }
int LayerOrder(BiTree bt) { LinkQueue Q; BiTree p; InitQueue(&Q); if(bt==NULL)return(FALSE); EnterQueue(&Q,bt); while(IsEmpty(Q)==0) { DeleteQueue(&Q,&p); printf("%c ",p->data); if(p->LChild)EnterQueue(&Q,p->LChild); if(p->RChild)EnterQueue(&Q,p->RChild); } printf("\n"); return(TRUE); }
void main(){ SeqQueue Q; char str[]="ABCDEFGH"; int i,length=8; char x; InitQueue(&Q); for(i=0;i<length;i++){ EnterQueue(&Q,str[i]); } DeleteQueue(&Q,&x); printf("出队列的元素为:%c\n",x); //显示输出出队列的元素 printf("顺序队列中的元素为:"); if(!QueueEmpty(Q)){ for(i=Q.front;i<Q.rear;i++) printf("%c",Q.queue[i]); } printf("\n"); system("pause"); }
void BFS(LGraph Graph ,Vertex V , void (*Visit)(Vertex) ) { Queue queue; Vertex v; PtrToAdjVNode w; queue = CreateQueue(20); AddQueue(queue,V); VisitedBFS[V] = 1;/*标记已经访问*/ Visit(V); while(queue->front != queue->rear){/*队列不为空*/ v = DeleteQueue(queue); for(w = Graph->G[v].FirstEdge ; w != NULL ; w = w->next ) if(VisitedBFS[w->AdjV] == 0){ AddQueue(queue,w->AdjV); VisitedBFS[w->AdjV] = 1; Visit(w->AdjV); } } }
int SizeOfBinaryTreeNonRecrusive(struct BinaryTreeNode *root) { int size = 0; struct BinaryTreeNode *temp; struct DynArrayQueue *Q = CreateQueue(); if(!root) { return size; } EnQueue(Q, root); while(!IsEmptyQueue(Q)) { temp = DeQueue(Q); size++; if (temp->left) { EnQueue(Q, temp->left); } if (temp->right) { EnQueue(Q, temp->right); } } DeleteQueue(Q); return size; }
void main() { Queue *queue = NULL; Element item; queue = CreateQueue(); item.key = 1; printf("Add ist element into the queue.\n"); AddQueue(queue, item); PrintQueue(queue); printf("Add 2st element into the queue.\n"); item.key = 2; AddQueue(queue, item); PrintQueue(queue); printf("Add 2st element into the queue.\n"); item.key = 3; AddQueue(queue, item); PrintQueue(queue); printf("Add 2st element into the queue.\n"); item.key = 4; AddQueue(queue, item); PrintQueue(queue); printf("Delete the top element from the queue.\n"); item = DeleteQueue(queue); printf("Delete %d\n", item.key); PrintQueue(queue); printf("Destroy the queue.\n"); DestoryQueue(queue); PrintQueue(queue); }
int main() { printf("############ WELCOME TO QUEUE OPERATIONS ############# \n \n"); int i=0; int size=0,data=0; queue *Q=(queue *)malloc(sizeof(queue)); while(1) { printf("\n 1)Create a Queue(Press 1)\n 2)Insert an element(Press 2)\n 3)Delete an element(Press 3)\n 4)Show the Queue(Press 4)\n 5)Delete a Queue(Press 5)\n 6)Show Queue Size(Press 6)\n 7)Exit(Press 7 to exit) \n"); scanf("%d",&i); switch(i) { case 1: printf("\nEnter the size of the stack= "); scanf("%d",&size); *CreateQueue(Q,size); printf("Enter the values of the element (Press -1 to stop)= \n"); while(1) { scanf("%d",&data); if(data==-1) break; else Enqueue(Q,data); }; break; case 2: printf("\nEnter the value of the element= "); scanf("%d",&data); if(data==-1) break; else Enqueue(Q,data); break; case 3: printf("The element deleted is =%d\n",Dequeue(Q)); break; case 4: if (flag==1) { if(!isEmptyQueue(Q)) { printf("\nThe elements of the Queue are: "); for(i=Q->head;i<=Q->tail;i++) printf("%d ",Q->array[i]); printf("\n"); } else printf("Queue is empty !!!! \n"); } else printf("There is no Queue !!! \n"); break; case 5: DeleteQueue(Q); printf("Queue is deleted !!! \n"); break; case 6: printf("The Queue size is = %d\n",Queuesize(Q)); break; case 7: exit(0); default: printf("Invalid option \n"); break; } } return 0; }
extern bool StraightenCode( ins_entry *jump ) /***********************************************/ { ins_entry *next; ins_entry *insert; ins_entry *hoist; ins_entry *end_hoist; oc_class cl; obj_length align; optbegin hoist = _Label( jump )->ins; if( hoist == NULL ) optreturn( false ); if( hoist == LastIns ) optreturn( false ); cl = PrevClass( hoist ); if( !_TransferClass( cl ) ) optreturn( false ); end_hoist = NULL; for( next = hoist; ; next = NextIns( next ) ) { if( next == jump ) { // pushing code down to jump if( end_hoist == NULL ) optreturn( false ); if( FindShort( hoist, end_hoist ) ) optreturn( false ); break; } if( next == NULL ) { // hauling code up to jump if( FindShort( jump, hoist ) ) optreturn( false ); break; } cl = _Class( next ); if( end_hoist == NULL && _TransferClass( cl ) ) { end_hoist = next; } } align = _ObjLen( hoist ); insert = jump; for( ;; ) { if( hoist == NULL ) { ChgLblRef( jump, AddNewLabel( LastIns, align ) ); next = LastIns; break; } next = NextIns( hoist ); DeleteQueue( hoist ); InsertQueue( hoist, insert ); if( hoist == jump ) optreturn( false ); insert = hoist; cl = _Class( hoist ); if( _TransferClass( cl ) ) { IsolatedCode( insert ); break; } hoist = next; } InsDelete = true; Untangle( next ); if( _Class( jump ) != OC_DEAD ) { Untangle( _Label( jump )->ins ); } optreturn( true ); }
bool ReadWriteDynQueue(const string &szIndex, const string &szDll, const string &szFunc, const char *pszQuery, const int &nSize, char *pBuffer, int &nRetSize, string szIDCUser = "******", string szAddr = "localhost") { static const string szLabel = "DYNPARAM"; static const string szDLLName = "DLL"; static const string szFUNC = "FUNC"; static const string szParam = "PARAMS"; static const char szSeparator = '#'; bool bRet = false; string szRefreshQueue(getRefreshQueueName(szIndex)), szQueueName(makeQueueName()); string szParamQueue(szQueueName + "_R"), szRetQueue(szQueueName + "_W"); CreateQueue(szRetQueue, 1, szIDCUser, szAddr); CreateQueue(szParamQueue, 1, szIDCUser, szAddr); CreateQueue(szRefreshQueue, 1, szIDCUser, szAddr); int nDllSize = static_cast<int>(szDll.size()) + 2, nFuncSize = static_cast<int>(szFunc.size()) + 2; char *pDll = new char[nDllSize]; if(pDll) { memset(pDll, 0, nDllSize); strcpy(pDll, szDll.c_str()); if(PushMessage(szParamQueue, szDLLName, pDll, nDllSize, szIDCUser, szAddr)) { char *pFunc = new char[nFuncSize]; if(pFunc) { memset(pFunc, 0, nFuncSize); strcpy(pFunc, szFunc.c_str()); if(PushMessage(szParamQueue, szFUNC, pFunc, nFuncSize, szIDCUser, szAddr)) { if(PushMessage(szParamQueue, szParam, pszQuery, nSize, szIDCUser, szAddr)) { int nQueueSize = static_cast<int>(szQueueName.size()) + 2; char *pszQueue = new char[nQueueSize]; if(pszQueue) { memset(pszQueue, 0, nQueueSize); strcpy(pszQueue, szQueueName.c_str()); if(PushMessage(szRefreshQueue, szLabel, pszQueue, nQueueSize, szIDCUser, szAddr)) { int nTimes = 0; while(!bRet) { if(nTimes >= 40) break; bRet = ReadFromRetQueue(szRetQueue, pBuffer, nRetSize, szIDCUser, szAddr); nTimes ++; } } delete []pszQueue; } } } delete []pFunc; } } delete []pDll; } DeleteQueue(szRetQueue, szIDCUser, szAddr); return bRet; }
int main() { int i,r; printf("Testing Queue\n"); Queue* queue = CreateQueue(); printf("Inserting values\n"); for(i = 0; i < 5 ; i++) { printf("%d\n",i); int result = QueueEnqueue(queue, i); if(result == 0) { printf("%d\n",i); } else { printf("Error in enqueuing queue\n"); } } printf("Removing values\n"); for(i = 0; i < 5 ; i++) { int result =QueueDequeue(queue, &r); if(result == 0) { printf("%d\n",r); } else { printf("Error in dequeuing queue\n"); } } DeleteQueue(queue); printf("\nTesting Stack\n"); Stack* stack = CreateStack(); for(i = 0; i < 5 ; i++) { int result = StackPush(stack, i); if(result == 0) { printf("%d\n",i); } else { printf("Error in pushing to stack"); } } for(i = 0; i < 5 ; i++) { int result = StackPop(stack, &r); if(result == 0) { printf("%d\n",r); } else { printf("Error in popping values"); } } DeleteStack(stack); return 0; }
int main() { struct timeval t1, t2; double elapsedTime; srand(time(NULL)); int i; int r; int result; printf("Testing Queue\n"); // start timer gettimeofday(&t1, NULL); Queue* queue = CreateQueue(); for(i = 0; i < NO_OF_ELEMENTS ; i++) { // Generate a random value and put that to stack r = rand(); result = QueueEnqueue(queue, r); if(result != 0) { printf("Error in enqueuing queue\n"); } } for(i = 0; i < NO_OF_ELEMENTS ; i++) { result =QueueDequeue(queue, &r); if(result != 0) { printf("Error in dequeuing queue\n"); } } DeleteQueue(queue); // Time calculation gettimeofday(&t2, NULL); elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0; elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; printf("Elapsed time %f\nQueue testing completed...\n", elapsedTime); printf("\nTesting Stack\n"); // start timer gettimeofday(&t1, NULL); Stack* stack = CreateStack(); for(i = 0; i < NO_OF_ELEMENTS ; i++) { // Generate a random value and put that to stack r = rand(); result = StackPush(stack, r); if(result != 0) { printf("Error in pushing to stack"); } } for(i = 0; i < NO_OF_ELEMENTS ; i++) { result = StackPop(stack, &r); if(result != 0) { printf("Error in poping stack"); } } DeleteStack(stack); // Time calculation gettimeofday(&t2, NULL); elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0; elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; printf("Elapsed time %f\nStack testing completed...\n", elapsedTime); return 0; }
void FindPath(PathFinder* pf) { //printf("(%d, %d) -> (%d, %d)\t", pf->startx, pf->starty, pf->endx, pf->endy); for (int i = 0; i < pf->map->width; i++) { for (int e = 0; e < pf->map->height; e++) { pf->nodeMap[i][e].f = 0; pf->nodeMap[i][e].g = 0; pf->nodeMap[i][e].h = 0; pf->nodeMap[i][e].open = NoList; pf->nodeMap[i][e].parent = NULL; } } DeleteQueue(pf->openList); pf->openList = CreateQueue(nodeMinCompare, pf->map->width * pf->map->height); int x = pf->startx; int y = pf->starty; // Step 1: Add starting node to the open list. AddOpen(pf, x, y, NULL); // Step 2: Repeat // If there's nothing in the open list anymore or we arrive at the destination, stop while (GetQueueSize(pf->openList) > 0) { //printf("%d ", GetQueueSize(pf->openList)); // a) Look for the lowest F cost square on the open list. Node* current = (Node*)QueueRemove(pf->openList); x = current->x; y = current->y; // b) Switch it to the closed list. current->open = OnClosedList; // c) For each of the 8 squares adjacent to this current square, attempt to add it // to the open list. // AddOpen checks for adjacent-validity and whether the node is a wall or not. AddOpen(pf, x - 0, y - 1, current); AddOpen(pf, x - 0, y + 1, current); AddOpen(pf, x - 1, y - 0, current); AddOpen(pf, x + 1, y - 0, current); // Diagonal Check if (pf->allowDiagonal) { AddOpen(pf, x - 1, y - 1, current); AddOpen(pf, x + 1, y - 1, current); AddOpen(pf, x - 1, y + 1, current); AddOpen(pf, x + 1, y + 1, current); } // Are we done? if (x == pf->endx && y == pf->endy && pf->nodeMap[pf->endx][pf->endy].open == OnClosedList) { // Step 3: Save Path DeletePath(pf); SavePath(pf, current); /* PathNode* p = pf->path; if (p == NULL) printf(" No Path?"); while (p) { printf("(%p) %d, %d", p, p->x, p->y); p = p->parent; } */ break; } } printf("Pathfinding done\n"); }
int main(void) { int select; /*保存选择变量*/ size_t pos; /*位序*/ Elem e; /*保存从函数返回的结点的值*/ Elem v; /*保存传递给函数的结点的值*/ size_t i= 0; LINKQUEUE Q; InitQueue(&Q); srand((int)time(NULL)); while (i < 10) { InsertQueue(&Q, rand()%20); ++i; } while (1) /*while_@1*/ { if (!Q.front) { printf("队列不存在!\n"); break; } system("cls"); Menu(); printf("请输入您的选择(1~10):"); scanf("%d", &select); getchar(); switch (select) /*switch_@1*/ { case 1: /*入队*/ v = InputValue("入队元素为:"); if (FAILE == InsertQueue(&Q, v)) { printf("入队失败!\n"); } else { printf("入队成功!\n"); } getchar(); break; case 2: /*输出队列*/ printf("队列为:"); TraveQueue(&Q); getchar(); break; case 3: /*出队*/ if (OK == DeleteQueue(&Q, &e)) { printf("出队成功,删除的元素是%d!\n", e); } else { printf("删除失败!\n"); } getchar(); break; case 4: /*输出队列的长度*/ printf("表长为: %d \n", QueueLength(&Q)); getchar(); break; case 5: /*清空队列*/ ClearQueue(&Q); printf("该表已经清空!\n"); getchar(); break; case 6: /*返回队头元素*/ if (OK == GetHead(&Q, &e)) { printf("该结点为:%d\n", e); } else { printf("不存在!\n"); } getchar(); break; case 7: /*判断队列是否为空*/ if (QueueEmpty(&Q) == TRUE) { printf("队列为空!\n"); } else { printf("队列非空!\n"); } getchar(); break; case 8: /*销毁队列*/ DestroyQueue(&Q); printf("队列已删除!\n"); getchar(); break; default: printf("请重新选择!\n"); getchar(); break; }/*switch_@1*/ } /*while_@1*/ return EXIT_SUCCESS; }