鱼C论坛

 找回密码
 立即注册
查看: 4263|回复: 5

有向图的邻接表建立出现问题

[复制链接]
发表于 2014-8-6 20:41:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. #include<stdio.h>
  2. #include<stdlib.h>

  3. #define MAX 100

  4. typedef struct
  5. {
  6.         int adjvex;
  7.         struct EdgeNode *next;
  8. }EdgeNode;

  9. typedef struct
  10. {
  11.         char data;
  12.         EdgeNode *firstNext;
  13. }VertexNode,AdjList[MAX];

  14. typedef struct
  15. {
  16.         AdjList adjList;
  17.         int numVertexes;
  18.         int numArcs;
  19. }GraphAdjList;

  20. int locate(GraphAdjList G,char c)
  21. {
  22.         int i=0;

  23.         while(G.adjList[i++].data!=c && i<G.numVertexes);

  24.         if(i<G.numVertexes)
  25.                 return i;
  26.         else return -1;

  27. }

  28. void CreateAdjList(GraphAdjList *G)
  29. {
  30.         int i,j,k;
  31.         EdgeNode *p,*q;
  32.         char m,n;

  33.         printf("请输入顶点和弧的数目\n");
  34.         scanf("%d %d",&G->numVertexes,&G->numArcs);
  35.        

  36.         for(k=0;k<G->numVertexes;k++)
  37.         {
  38.                 printf("请输入第%d个顶点的信息\n",k);
  39.                 scanf("%c",&G->adjList[k].data);
  40.                 G->adjList[k].firstNext=NULL;
  41.         }

  42.         for(k=0;k<G->numArcs;k++)
  43.         {
  44.                 printf("请按顺序输入弧的弧头v和弧尾w\n");
  45.                 scanf("%c %c",&m,&n);

  46.                 q=(EdgeNode *)malloc(sizeof(EdgeNode));

  47.                 i=locate(G,m);
  48.                 j=locate(G,n);

  49.                 q->adjvex=j;

  50.                 if( G->adjList[i].firstNext!=NULL )
  51.                         G->adjList[i].firstNext=q;
  52.                 else
  53.                 {
  54.                         p=G->adjList[i].firstNext->next;
  55.                         while(p)
  56.                         {
  57.                                 p=p->next;
  58.                         }
  59.                         p->next=q;
  60.                 }
  61.         }
  62. }

  63. void print(GraphAdjList *G)
  64. {
  65.         int i;
  66.         EdgeNode *p;

  67.         for(i=0;i<G->numVertexes;i++)
  68.         {
  69.                 printf("%c",G->adjList[i].data);
  70.                 p=G->adjList[i].firstNext;
  71.                 while(p)
  72.                 {
  73.                         printf("->%d",p->adjvex);
  74.                         p=p->next;
  75.                 }
  76.                 printf("->NULL\n");
  77.         }

  78.         free(p);
  79. }


  80. int main()
  81. {
  82.         GraphAdjList *G;
  83.         CreateAdjList(G);
  84.         print(G);

  85.         return 0;
  86. }
复制代码


小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2014-8-6 20:42:06 | 显示全部楼层
Compiling...
fuck.c
D:\×à&#195;&#230;\WorkSpace\fuck.c(61) : error C2115: 'function' : incompatible types
D:\×à&#195;&#230;\WorkSpace\fuck.c(61) : warning C4024: 'locate' : different types for formal and actual parameter 1
D:\×à&#195;&#230;\WorkSpace\fuck.c(62) : error C2115: 'function' : incompatible types
D:\×à&#195;&#230;\WorkSpace\fuck.c(62) : warning C4024: 'locate' : different types for formal and actual parameter 1
D:\×à&#195;&#230;\WorkSpace\fuck.c(70) : warning C4133: '=' : incompatible types - from 'struct EdgeNode *' to 'struct EdgeNode *'
D:\×à&#195;&#230;\WorkSpace\fuck.c(73) : warning C4133: '=' : incompatible types - from 'struct EdgeNode *' to 'struct EdgeNode *'
D:\×à&#195;&#230;\WorkSpace\fuck.c(75) : warning C4133: '=' : incompatible types - from 'struct EdgeNode *' to 'struct EdgeNode *'
D:\×à&#195;&#230;\WorkSpace\fuck.c(92) : warning C4133: '=' : incompatible types - from 'struct EdgeNode *' to 'struct EdgeNode *'
Error executing cl.exe.

fuck.obj - 2 error(s), 6 warning(s)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-6 22:34:20 | 显示全部楼层
好难啊 有没有人帮我啊
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-7 07:47:33 | 显示全部楼层
我只能一个人默默的哭泣:curse:
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2014-8-9 19:28:04 | 显示全部楼层
似懂非懂所发生的:ton:
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2014-8-11 00:34:42 | 显示全部楼层
可以将破解的结果以文本文档的形式保存在指定目录下。

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-7 22:24

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表