网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

c语言mrncy函数 c语言main函数用法

c语言 数据结构基本功能要求:

#include "stdio.h"

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名注册虚拟主机、营销软件、网站建设、柘荣网站维护、网站推广。

#define MAX 50

typedef struct LNode{

int data;

struct LNode *next;

}LNode;

void OutputDegree(int matrix[MAX][MAX], int n);

void Insert(LNode *head, int data);

void list(LNode *head);

void createAdjList(int matrix[MAX][MAX], int n, LNode *head[]);

void main()

{

int matrix1[MAX][MAX] = {{0,1,1},{1,0,1},{0,0,0}};

int matrix2[MAX][MAX] = {{0,1,0,1,0},{1,0,1,0,0},{0,1,0,1,1},{1,0,1,0,0},{0,0,1,0,0}};

int n; /* 顶点数 */

LNode *head[MAX];

int i;

n = 3;

printf("List degree of all vertex : \n");

OutputDegree(matrix1, n);

for(i=0; in; i++)

{

head[i] = (LNode *)malloc(sizeof(LNode));

head[i]-data = i+1;

}

createAdjList(matrix1, n, head);

printf("Adjancency List : \n");

for(i=0; in; i++)

{

printf("%d : ", head[i]-data);

list(head[i]);

printf("\n");

}

n = 5;

printf("List degree of all vertex : \n");

OutputDegree(matrix2, n);

for(i=0; in; i++)

{

head[i] = (LNode *)malloc(sizeof(LNode));

head[i]-data = i+1;

}

createAdjList(matrix2, n, head);

printf("Adjancency List : \n");

for(i=0; in; i++)

{

printf("%d : ", head[i]-data);

list(head[i]);

printf("\n");

}

}

/* 输出顶点的度 */

void OutputDegree(int matrix[MAX][MAX], int n)

{

int InDegree[MAX]; /* 入度 */

int OutDegree[MAX]; /* 出度 */

int i, j;

for(i=0; in; i++)

{

InDegree[i] = OutDegree[i] = 0;

for(j=0; jn; j++)

{

InDegree[i] += matrix[j][i];

OutDegree[i] += matrix[i][j];

}

}

for(i=0; in; i++)

{

printf("vertex %d : In - %d, Out - %d\n", i+1, InDegree[i], OutDegree[i]);

}

}

void Insert(LNode *head, int data)

{

LNode *pre = head-next;

LNode *temp;

temp = (LNode*)malloc(sizeof(LNode));

temp-data = data;

temp-next = NULL;

if(pre == NULL)

{

head-next = temp;

return;

}

for(; pre-next!=NULL; pre=pre-next);

pre-next = temp;

}

void list(LNode *head)

{

LNode *curr;

for(curr=head-next; curr!=NULL; curr=curr-next)

{

printf("%d\t", curr-data);

}

}

/* 根据邻接矩阵构建邻接表 */

void createAdjList(int matrix[MAX][MAX], int n, LNode *head[])

{

int i, j;

for(i=0; in; i++)

{

for(j=0; jn; j++)

{

if(matrix[i][j] != 0)

Insert(head[i], j+1);

}

}

}


名称栏目:c语言mrncy函数 c语言main函数用法
标题链接:http://bjjierui.cn/article/dosipid.html

其他资讯