error C2143: syntax error : missing ';' before '['
error C2143: syntax error : missing ';' before '{'
那怎么办
追答struct
{
vextype adjvex;
adjtype lowcost;
} closedge[30];
for (int j = 0; j < n; j++)
{
if (j != k)
{
closedge[j].adjvex = u;
closedge[j].lowcost = G.arcs[k][j];
}
}
closedge[k].lowcost = 0;
struct{
vextype adjvex;
adjtype lowcost;
}closedge[30];
for(int j=0;j<n;j++)
if(j!=k)
closedge[j]={u,G.arcs[k][j]};
closedge[k].lowcost=0;
编译出错,意思是结构体数组不能这样赋值,不知道怎么办
结构体 struct 只有初次使用是才能用{ }赋值,
struct{
vextype adjvex;
adjtype lowcost;
}closedge[30];
for(int j=0;j<n;j++)
if(j!=k)
closedge[j]={u,G.arcs[k][j]}; //closedge[j]是一个引用,或者说是指针
closedge[k].lowcost=0;