# C语言中结构体的成员数组赋值问题

0

``` 1 #include <stdio.h>
2 #include <stdlib.h>
3 #define MAXVER 6
4 //定义图的数据结构
5 struct Graph
6 {
7     int arc[MAXVER][MAXVER];//邻接矩阵
8     int ver[MAXVER];//顶点集
9     int numVertexes;//图的顶点总数，边数
10     int numEdeges;
11 };
12 //定义边的数据结构
13  struct Edge
14 {
15     int begin;
16     int end;
17     int weight;//边长
18 };
19 void main()
20 {
21     struct Edge temp;
22
23
24     //创建图，并初始化
25     struct Graph *myGraph=(struct Graph*)malloc(sizeof(struct Graph));
26     //创建并初始化线性表a
27     struct Edge a[10]={{1,2,6},{1,3,1},{1,4,5},{2,3,5},{2,5,3},{3,4,5},{3,5,6},{3,6,4},{4,6,2},{5,6,6}};
28     struct Edge b[10];
29     myGraph->ver[MAXVER]={0,0,0,0,0,0};
30     //初始化邻接矩阵
31     myGraph->arc[MAXVER][MAXVER]={{0,6,1,5,0,0},{6,0,5,0,3,0},{1,5,0,5,6,4},{5,0,5,0,0,2},{0,3,6,0,0,6},{0,0,4,2,6,0};
32     //初始化顶点数，边数
33     myGraph->numVertexes = 6;
34     myGraph->numEdeges = 10;
35 }```

04.c(29) : error C2059: syntax error : '{'

04.c(31) : error C2059: syntax error : '{'

0

0

29 行改为：`myGraph->ver[MAXVER]={{0,0,0,0,0,0}};`;

31 行后面少了一个 `}`

CodeHsu | 园豆：5468 (大侠五级) | 2016-10-09 17:21

0

您需要登录以后才能回答，未注册用户请先注册