乱图乱画(不知道自己写的什么鬼)
来源:互联网 发布:成绩分析软件 编辑:程序博客网 时间:2024/05/17 02:38
#include <stdio.h>#include <malloc.h>#include <Windows.h>#include <conio.h>#include <queue>#include <cstdlib>#include <iostream>using namespace std;#define unmax 10000#define White 0#define Gray 1#define Black 2typedef struct point{int color ;int d ;struct point *pi ;int value ;}*Ppoint;typedef struct node{Ppoint key ;struct node *next ;}*Pmap;Pmap Create_Link(){Pmap H,L,P;int num ;H = (Pmap)malloc(sizeof(struct node));H->key = (Ppoint)malloc(sizeof(struct point));P = (Pmap)malloc(sizeof(struct node));P->key = (Ppoint)malloc(sizeof(struct point));if (!H){printf("error\n");}H->next = NULL ;P = H ;scanf("%d",&num);while(num!=(-1)){L = (Pmap)malloc(sizeof(struct node));L->key = (Ppoint)malloc(sizeof(struct point));L -> key->value = num ;L->next = P->next ;P->next = L ;P = L ;scanf("%d",&num);}return H ;}void Out_Putlink(Pmap Ptr){if (!Ptr){printf("output error\n");exit(0);}Pmap ptr = (Pmap)malloc(sizeof(struct node));ptr->key = (Ppoint)malloc(sizeof(struct point));ptr = Ptr->next ;while(ptr){printf("%d ",ptr->key->value);ptr = ptr->next ;}printf("\n");}void BFS(Pmap G[] , Ppoint s ,int n){Pmap u ;int i ;for (i =0 ; i < n ;i++){u = G[i]->next;while(u){if (u->key!=s){u->key->color = White ;u->key->d = unmax ;u->key->pi = NULL ;}u = u->next ;}}s->color = Gray ;s->d = 0;s->pi = NULL ;queue<Ppoint>Q ;Q.push(s);while(!Q.empty()){Ppoint x,v;x = Q.front(); Q.pop();Pmap ptr ;int i ;for (i = 0 ; i< n ; i++){if (G[i]->next->key == x){ptr = G[i] ;}}while(ptr->next){v = ptr->next->key;if (v->color==White){v->color = Gray ;v->d++;v->pi = x ; }Q.push(v);}x->color = Black ;ptr->next = ptr->next->next ;}}void Print_Path(Pmap G[],Ppoint s ,Ppoint v) {if (s==v)printf("%d",s->value);else if(v->pi==NULL)printf("no path\n");elsePrint_Path(G,s,v->pi);printf("%d",v->value);}int main(){Pmap Ptr[3] ;int i ;for (i=0 ; i < 3 ;i ++){Ptr[i] = (Pmap)malloc(sizeof(struct node));Ptr[i]->key =(Ppoint)malloc(sizeof(struct point));Ptr[i] = Create_Link();}Ppoint s ;//s->color=1;s->d=0;s->pi=NULL;s->value = 1;BFS(Ptr,s,3);for (i=0 ; i < 3 ;i ++)Out_Putlink(Ptr[i]);getch();return 0 ;}乱写一通,我要放弃这样的图的构造了。。。。表示累觉不爱
0 0
- 乱图乱画(不知道自己写的什么鬼)
- 不知道写什么
- 不知道写什么
- 不知道写什么
- 不知道写什么
- 不知道写什么。
- 真的不知道写什么好啊!
- 不知道自己想要什么
- 不知道写什么了
- 不知道要写什么。
- 不知道该写什么
- 不知道该写什么
- 不知道写什么东西
- 不知道写些什么
- 不知道写点什么
- 想自己写个项目,想了很久都不知道该写什么
- 开通CSDN的blog,不知道写些什么好!
- 刚开通的博客 不知道写什么好呢
- 添加考试功能总结
- 用Python和Pygame写游戏-从入门到精通(10)
- 详解Oracle的几种分页查询语句
- 文字阴影效果
- vb(3) 将excel导入grid
- 乱图乱画(不知道自己写的什么鬼)
- Scala语言与Play框架入门教程
- 第三方登录 QQ WEIBO
- python模拟登陆人人网(通过BeautifulSoup module)
- Android SimpleAdapter显示ListView、GridView
- CentOS6.5菜鸟之旅:文件权限详解
- 以HttpGet方法获取URL数据并转换成指定编码格式的字符串
- 操作系统实践(3)——火箭助推器
- 框架嵌套实例