久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

dequeue函數C語言 queue c語言

一道C語言數據結構隊列代碼 調用出隊子函數dequeue時不知哪里出錯,運行無輸出。

bool?dequeue(sqqueue?*q,char?e)

成都創(chuàng)新互聯主要從事網頁設計、PC網站建設(電腦版網站建設)、wap網站建設(手機版網站建設)、響應式網站開發(fā)、程序開發(fā)、網站優(yōu)化、微網站、微信小程序開發(fā)等,憑借多年來在互聯網的打拼,我們在互聯網網站建設行業(yè)積累了豐富的成都網站設計、網站建設、網站設計、網絡營銷經驗,集策劃、開發(fā)、設計、營銷、管理等多方位專業(yè)化運作于一體。

{

if(queueempty(q))

return?false;

q-front++;

e=q-date[q-front];

return?true;

}

一個很簡單的小問題,dequeue的參數e 應該是引用哦

求一個廣度優(yōu)先算法的實例及其C語言程序(L-dequeue)

#include stdio.h

#define max 100

typedef struct anode

{

int adjvex; //邊的終點位置

struct anode *nextarc;

}arcnode;

typedef struct node

{

int data;

arcnode *firstout;

}vnode;

typedef struct

{

vnode adjlist[max];

int n;

int e;

}Agraph;

static int visit[max];

//深度遍歷

void DFS(Agraph G,int v) //v為初始頂點編號

{

int k;

arcnode *p;

for(k=0;kG.n;k++)

visit[k]=0;

printf("%d ",v);

p=G.adjlist[v].firstout;

while(p)

{

if(!visit[p-adjvex])

DFS(G,p-adjvex);

p=p-nextarc;

}

}

void BFS(Agraph G,int v)

{

arcnode *p;

int q[max];

int front=0;

int rear=0;

int w,i;

for(i=0;iG.n;i++)

visit[i]=0;

printf("%d ",v);

visit[v]=1;

rear=(rear+1)%max;

q[rear]=v;

while(front!=rear)

{

front=(front+1)%max;

w=q[front];

p=G.adjlist[w].firstout;

while(p)

{

if(!visit[p-adjvex])

{

printf("%d ",p-adjvex);

visit[p-adjvex]=1;

rear=(rear+1)%max;

q[rear]=p-adjvex;

}

p=p-nextarc;

}

printf("\n");

}

}

//層序遍歷二叉樹

struct btnode

{

int data;

btnode *lchild,*rchild;

};

void level(struct btnode *bt)

{

if(!bt)

return;

btnode *q[max];

int front,rear;

front=0;

rear=0;

printf("%d ",bt-data);

rear=(rear+1)%max;

q[rear]=bt;

while(front!=rear)

{

front=(front+1)%max;

bt=q[front];

if(bt-lchild)

{

printf("%d ",bt-lchild-data);

rear=(rear+1)%max;

q[rear]=bt-lchild;

}

if(bt-rchild)

{

printf("%d ",bt-rchild-data);

rear=(rear+1)%max;

q[rear]=bt-rchild;

}

}

}

void DFS1(Agraph G,int v)

{

arcnode *p;

printf("%d ",v);

visit[v]=1;

p=G.adjlist[v].firstout;

while(p)

{

if(!visit[p-adjvex])

{

DFS1(G,p-adjvex);

}

p=p-nextarc;

}

}

void level1(struct btnode *bt)

{

if(!bt)

return;

printf("%d ",bt-data);

struct btnode *q[max];

int front=0;

int rear=0;

rear=(rear+1)%max;

q[rear]=bt;

while(front!=rear)

{

front=(front+1)%max;

bt=q[front];

if(bt-lchild)

{

printf("%d ",bt-lchild-data);

rear=(rear+1)%max;

q[rear]=bt-lchild;

}

if(bt-rchild)

{

printf("%d ",bt-rchild-data);

rear=(rear+1)%max;

q[rear]=bt-rchild;

}

}

}

void BFS1(Agraph G,int v)

{

int q[max];

int front=0;

int rear=0;

int i;

for(i=0;iG.n;i++)

visit[i]=0;

printf("%d ",v);

visit[v]=1;

rear=(rear+1)%max;

q[rear]=v;

arcnode *p;

while(front!=rear)

{

front=(front+1)%max;

i=q[front];

p=G.adjlist[i].firstout;

while(p)

{

if(!visit[p-adjvex])

{

printf("%d ",p-adjvex);

visit[p-adjvex]=1;

rear=(rear+1)%max;

q[rear]=p-adjvex;

}

p=p-nextarc;

}

}

}

C語言隊列的插入與刪除

#include?stdio.h

#include?stdlib.h

#define?MAXQSIZE?100?????//最大隊列長度

#define?OK?1

#define?ERROR?0

#define?OVERFLOW?-2

typedef?struct

{

int?*base;

int?front;

int?rear;?????//尾指針,若隊列不空,指向隊列尾元素的下一個位置

}SqQueue;

void?InitQueue(SqQueue?*Q)

{

Q-front?=?Q-rear?=?0;

if?(Q-base?==?NULL)?{

Q-base?=?(int*)malloc(sizeof(int)*?MAXQSIZE);

}

}

void?DesQueue(SqQueue?*Q)?{

free(Q-base);

Q-base?=?NULL;

Q-front?=?Q-rear?=?0;

}

int?QueueLength(SqQueue?*Q)

{

if?(Q-base?==?NULL)?return?ERROR;

return?(Q-rear?-?Q-front?+?MAXQSIZE)?%?MAXQSIZE;

}

void?display(SqQueue?*Q)

{

int?i;

if?(Q-base?==?NULL)?{

printf("\n?ERROR?");

return;

}

for?(i?=?Q-front;?i?!=?Q-rear;?i++)?{

i?=?i?%?MAXQSIZE;

printf("%3d",?Q-base[i]);

}

printf("\n");

}

int?InQueue(SqQueue?*Q,?int?e)

{

if?(Q-base?==?NULL)?return?ERROR;

if?((Q-rear?+?1)?%?MAXQSIZE?==?Q-front)

return?OVERFLOW;

Q-base[Q-rear]?=?e;

Q-rear?=?(Q-rear?+?1)?%?MAXQSIZE;

return?OK;

}

int?DeQueue(SqQueue?*Q,?int?m)

{

int?i?=?0;

if?(Q-base?==?NULL)?return?ERROR;

if?(Q-front?==?Q-rear)

return?ERROR;

while?(i?!=?m??Q-front?!=?Q-rear)

{

printf("\n%dDeleted\n",?Q-base[Q-front]);

Q-front?=?(Q-front?+?1)?%?MAXQSIZE;

i++;

}

if?(i?!=?m)?{

printf("\n?ERROR?");

return?ERROR;

}

return?OK;

}

void?main()

{

int?m,?n,?d,?i;

SqQueue?Q?=?{?0,?0,?0?};

InitQueue(Q);

printf("請輸入要插入的元素個數:");

scanf("%d",?m);

printf("要插入的元素:");

for?(i?=?1;?i?=?m;?i++)

{

scanf("%d",?n);

InQueue(Q,?n);

}

printf("插入元素后,隊列中的元素為:");

display(Q);

printf("隊列長度為:");

printf("%d\n",?QueueLength(Q));

printf("輸入要刪除的元素個數:");

scanf("%d",?d);

DeQueue(Q,?d);

printf("\n刪除元素后,隊列中元素為:");

display(Q);

printf("\n");

DesQueue(Q);

}

求大家?guī)兔?關于C語言里的queue

這是鏈表的,部分是c++的輸入輸出,改一下cout,cin換成printf,scanf就行了

#includestdio.h

#includeiostream

#define MAX 30

using namespace std;

typedef struct pqueue

{

char str[MAX];

int priority;

pqueue* next;

}pqueue;

int enqueuepriority(pqueue *pq, char str[MAX], int priority)

{

if(priority0)

{

pqueue *p=(pqueue*)malloc(sizeof(pqueue));

for(int i=0;iMAX;i++)

p-str[i]=str[i];

p-priority=priority;

p-next=pq-next;

pq-next=p;

return 1;

}

else return 0;

}

char* dequeue(pqueue *pq)

{

pqueue *p;

if(pq-next!=NULL)

{

p=pq-next;

pq-next=pq-next-next;

return p-str;

}

else return "";

}

int main()

{

cout"(1) Enqueue (single)"endl;

cout"(2) Enqueue (multiple)"endl;

cout"(3) Dequeue (single)"endl;

cout"(4) Dequeue (all)"endl;

cout"(5) Quit"endl;

int re=0,t=1;

static char* str=new char[MAX];

int priority=0;

pqueue *pq=(pqueue*)malloc(sizeof(pqueue));

pq-next=NULL;

while(re!=5)

{

cout"Choose an action:";

cinre;

switch(re)

{

case 1:

cout"Enter a name to save and its priority"endl;

scanf("%s%d",str,priority);

if(enqueuepriority(pq,str,priority))

break;

else

{

cout"INPUT ERROR!!"endl;

break;

}

case 2:

cout"Enter names to save and their priority. Enter “done” to quit"endl;

do

{

scanf("%s",str);

if(strcmp(str,"done")!=0)

{

scanf("%d",priority);

enqueuepriority(pq,str,priority);

}

else t=0;

}while(t==1);

break;

case 3:

str=dequeue(pq);

if(str=="")

cout"NULL"endl;

else

printf("%s\n",str);

break;

case 4:

while(pq-next!=NULL)

{

printf("%s\n",dequeue(pq));

}

break;

case 5: break;

default:

cout"INPUT ERROR!!"endl;

break;

}

}

delete [] str;

return 0;

}

分享題目:dequeue函數C語言 queue c語言
網頁URL:http://sd-ha.com/article4/doijioe.html

成都網站建設公司_創(chuàng)新互聯,為您提供域名注冊網站設計公司、移動網站建設用戶體驗、網站維護靜態(tài)網站

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯

網站托管運營