编写算法实现建立图的邻接表StatusCreateAG(ALGraph&G){intn,e,k,i,j;cout<<'请输入顶点数:';cin>>n;cout<<'请输入边数:';cin>>e;G.vernum=n;G.arcnum=e;//建立顶点数组for(k=0;k>G.vertices[k].data;G.vertices[k].firstarc=NULL;}//建立邻接表VertexTypev1,v2;ArcNode*p,*q;for(k=0;k>v1>>v2;i=LocateVex(G,v1);if(i<0||i>G.vernum-1)returnERROR;j=LocateVex(G,v2);if(j<0||j>G.vernum-1)returnERROR;if(i==j)returnERROR;p=newArcNode;if(!p)returnERROR;p->adjvex=j;p->nextarc=NULL;q=G.vertices[i].firstarc;if(!q)G.vertices[i].firstarc=p;else{while(q->nextarc)__________//指针定位于邻接表的尾结点q->nextarc=p;}}returnOK;}
举一反三
- 编写算法实现建立图的邻接表 StatusCreateAG(ALGraph &G) { int n,e,k,i,j; cout<<"请输入顶点数:"; cin>>n; cout<<"请输入边数:"; cin>>e; G.vernum=n; G.arcnum=e; // 建立顶点数组 for(k=0;k>G.vertices[k
- Working-class parents teach their children to be obedient and show respect to adults. A: A B: B C: C D: D E: E F: F G: G H: H I: I J: J K: K L: L M: M N: N O: O P: P Q: Q
- In theory, free competition is supposed to reduce the margin of profits to the minimum. A: A B: B C: C D: D E: E F: F G: G H: H I: I J: J K: K L: L M: M N: N O: O P: P Q: Q
- Contrary to what researchers expected, happiness may not benefit the human body. A: A B: B C: C D: D E: E F: F G: G H: H I: I J: J K: K L: L M: M N: N O: O P: P Q: Q
- The automated assessment technology is sometimes used to double check the work of human graders. A: A B: B C: C D: D E: E F: F G: G H: H I: I J: J K: K L: L M: M N: N O: O P: P Q: Q