日 历

2008 8.28 Thu
     12
3456789
10111213141516
17181920212223
24252627282930
31      
«» 2008 - 8 «»

文章搜索

日志文章列表

2007年12月12日 14:39:46

无向图邻接表的建立

#define maxnode 40
#define null 0
#include<stdio.h>
typedef struct st_arc
{int adjvex;
int weight;
struct st_arc *nextarc;
}arcnode;
typedef struct
{int vertex;
struct st_arc *firstarc;
}vernode;
typedef vernode adjlist[maxnode];
void print(vernode g[],int n)
{
arcnode *q;
int i;
printf("adjacency list of the graph:\n");
for(i=0;i<n;i++)
  {printf("\t%d\t",i);
  printf("%d\t",g.vertex);
  q=g.firstarc;
  while(q!=..

阅读全文>>

Tags: 无向图邻接表  

类别: 数据库 |  评论(0) |  浏览(2362) |  收藏
2007年12月12日 13:57:43

堆排序

#include<stdio.h>
#define max 40
typedef struct
{int key;
char name;
}datatype;
datatype x[max];

void creatheap(datatype x[],int l,int n)
{
int i,j,flag;
datatype swap;
i=l;
j=2*i+1;
swap=x;
flag=0;
while(j<=n-1&&flag!=1)
{if(j<n-1&&x[j].key>x[j+1].key)
j++;
if(swap.key<x[j].key)
flag=1;
else
{x=x[j];
i=j;
j=2*i+1;
x=swap;
}
}
}


void getsort(datatype x[],int n)
{
int i;
printf("recorder:");
for(i=0;i<n;i++)
scanf("%d"..

阅读全文>>

Tags: 堆排序  

类别: 数据库 |  评论(0) |  浏览(1086) |  收藏