C语言图数据结构邻接链表创建及打印代码优化修复
{/'title/':/'C语言图数据结构邻接链表创建及打印代码优化修复/',/'description/':/'本文修复了C语言中使用邻接链表创建图的代码逻辑错误,并优化了打印图的代码。修复后的代码能够正确创建和打印图的邻接链表。/',/'keywords/':/'C语言, 图数据结构, 邻接链表, 代码修复, 优化/',/'content/':/'void creategraph(adjgraph *&G, int A[maxv][maxv] ,int n ) {//n//tG=(adjgraph *)malloc(sizeof(adjgraph));//n//tint i,j;//n//tanode *p;//n//tfor(i=0; i<n; i++)//n//t/tG->adjlist[i].firstarc=NULL;//n//tfor(i=0; i<n; i++) {//n//t/tfor(j=n-1; j>=0; j--) {//n//t/t/tif(A[i][j]!=0&&A[i][j]!=inf) {//n//t/t/t/tp=(anode *)malloc(sizeof(anode));//n//t/t/t/tp->adjvex=j;//n//t/t/t/tp->weight=A[i][j];//n//t/t/t/tp->nextarc=G->adjlist[i].firstarc;//n//t/t/t/tG->adjlist[i].firstarc=p;//n//t/t/t}//n//t/t}//n//t}//n//tG->n=n;//n}//n//nvoid printgraph(adjgraph *G ) {//n//tint i;//n//tanode *p;//n//tfor(i=0; i
原文地址: https://www.cveoy.top/t/topic/qg1i 著作权归作者所有。请勿转载和采集!