这是 C (adjacency.c) 中的 prog,它检查是否存在从节点 a 到节点 b 的有向图方式
# include <stdio.h>
# include <stdlib.h>
#define N 11
#define FALSE 0
#define TRUE 1
typedef int[N][N] adj_mat;
int path (adj_mat A, int u, int v)
void main()
{
adj_mat Matrix;
int dadnode, sonnode;
printf("bla-bla-bla enter nodes.\n");
printf("Press Ctrl+Z after finishing of bla-bla-bla all the nodes\n");
do {
printf("Enter the number of first node\n");
scanf("%d", &dadnode);
printf("Enter the number of second node\n");
scanf("%d", &sonnode;);
if ((dadnode < sonnode) && (sonnode <= N) && (dadnode > 0))
Matrix[dadnode][sonnode] = 1;
} while ( (dadnode != EOF ) && (sonnode != EOF));
printf("Now enter u and v nodes to check if exists way from u node to we node\n")
printf("Enter the number of u node\n");
scanf("%d", &dadnode);
printf("Enter the number of v node\n");
scanf("%d", &sonnode;);
if ((dadnode < sonnode) && (sonnode <= N) && (dadnode > 0))
{
if(path(Matrix,dadnode,sonnode) == TRUE )
printf ("Exists way from node u to node v ");
}
else printf printf ("Not exists way from node u to node v ");
}
int path (adj_mat A, int u, int v)
{
if (v >= u)
return FALSE;
int nodenum;
for(nodenum = v - 1; nodenum > 0; nodenum-- )
{
if (A[nodenum][v] == TRUE)
{
if (nodenum == u) /
return TRUE;
else if (path (adj_mat A, int u, int nodenum))
return TRUE;
}
}
return FALSE;
}
当我输入命令时
gcc -o 邻接 -ansi adjacency.c
我明白了
adjacency.c:8:错误:预期标识符或 '(' 在 '[' 标记之前
adjacency.c:10: 错误:在 'A' 之前需要 ')'</p>
adjacency.c:58: 错误: 'A' 之前的预期')'</p>
怎么修 ?
更新:感谢大家的帮助。编译。