狼中之狼 发表于 2006-1-3 14:52

那位大哥能帮我把这程序写上注释吗?

那位大哥能帮我把这程序写上注释吗?
C语言的 看的不是很懂,所以帮帮忙。

随便给我组测试的数据。谢谢

#include <stdio.h>
#include <stdlib.h>
#define MAXN 30

typedef struct
{
    int v1,v2;
    int weight;
}EDGE;

typedef struct
{
    int Vnum;
    EDGE e;
}Graph;

typedef struct node
{
    int v;
    struct node *next;
}Alist;

void heapadjust(EDGE data[],int s,int m)      /*建立小根堆 */
{
    int j;
    EDGE t;
    t=data;
    for(j=2*s+1;j<=m;j=j*2+1)
    {
      if(j<m && data.weight>data.weight)
            ++j;
      if(!(t.weight>data.weight))
            break;
      data=data;
      s=j;
    }
    data=t;
}

int creat_graph(Graph *p)
{
    int k=0;
    int n;
    int v1,v2;
    int w;
    printf("vertex number of the graph:");   /*连通图的顶点数字*/
    scanf("%d",&n);
    if(n<1)
      exit(0);
    p->Vnum=n;
    do
    {
      printf("edge(vertex1,vertex2,weight):");
      scanf("%d%d%d",&v1,&v2,&w);
      if(v1>=1 && v1<=n && v2>=1 && v2<=n)      /*建立图的邻接矩阵*/
      {
            p->e.v1=v1-1;

天命 发表于 2006-1-3 15:02

现在手上没有离散的课本,全忘了,暂时帮不了楼主,帮顶的

用程序诠释生命 发表于 2006-1-3 15:10

真的不知道还有哪些地方需要注释了。

狼中之狼 发表于 2006-1-3 15:18

Originally posted by 用程序诠释生命 at 2006-1-3 03:10 PM:
真的不知道还有哪些地方需要注释了。

给组测试的数据

我自己慢慢看

盼望 发表于 2006-1-4 10:29

怎么没有完整的程序?
页: [1]
查看完整版本: 那位大哥能帮我把这程序写上注释吗?