#include "stdio.h"
#include "stdlib.h"
#include "iostream.h"
#define N 10
typedef struct edge
{
int stvex[N];//边起点
int edvex[N];//边终点
int lowcost[N];//权值,按大小顺序排列
struct edge *next;
}edge;
int KLSKER (int lowcost[N],int stvex[N],int edvex[N] )
{
int e,h;
struct edge *stp;
struct edge *edp;
for(int i=2;i
{
for(int j=0;j
{
if((stvex[i]==stvex[j])||(stvex[i]=edvex[j]))
return stvex[j]||edvex[j];
if((edvex[i]==stvex[j])||(edvex[i]==edvex[j]))
return stvex[j]||edvex[j];
if(stvex[j]==edvex[j])//??????
stp=&stvex[i];
e=*stp;
stp=stp->next;
free(stp);
edp=&edvex[i];
h=*edp;
edp=edp->next;
free(edp);
}
}
cout<<"("<
}
void main()
{
int e,edgenum,vexnum;
cout
cin>>vexnum;
cout<<"请输入边数"<
cin>>edgenum;
cout<<"请大小顺序输入各边权值,相同权值并列排后"<
for(int i=0;i
{
cin>>e;
edge->lowcost[i]=e;
}
cout<<"请将边的2个顶点依次输入,编号小的边视为起点。输入的顶点与相应的边权值对应"<
cout
for(int j=0;j
{
cin>>e;
edge->stvex[j]=e;
}
cout<<"请输入边终点"<
for(int k=0;k
{
cin>>e;
edge->edvex[k]=e;
}
KLSKER();
return 0;
}
我自己编的克鲁斯卡尔算法求最小生成树,但是编译不出,求赐教
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
0条回答 默认 最新
悬赏问题
- ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
- ¥15 微信公众号自制会员卡没有收款渠道啊
- ¥15 stable diffusion
- ¥100 Jenkins自动化部署—悬赏100元
- ¥15 关于#python#的问题:求帮写python代码
- ¥20 MATLAB画图图形出现上下震荡的线条
- ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
- ¥15 perl MISA分析p3_in脚本出错
- ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
- ¥15 ubuntu虚拟机打包apk错误