Tony Hak
04-12-2007, 13:22
ciao ! .. ho questa funzione :
int g_add(graph *G, int u, int v, int d)
{
edge *new,*e;
int trovato =0;
/*code*/
new = (edge*)malloc(sizeof(edge));
if (new==NULL)
printf("ERRORE: impossibile allocare memoria \n");
else
{
new->key=v;
new->dist=d;
new->next=NULL;
if (G->adj[u] == NULL) /*il nodo u non ha archi */
G->adj[u] = new;
else
{
e=G->adj[u];
if (e->key != v) /*controllo sul primo nodo*/
{
while ((e->next!=NULL) && (trovato == 0))
{
if (e->next->key == v)
{ /*controllo dal secondo nodo*/
trovato =1;
distanza = e->next->dist;
}
else
e=e->next;
}
if (trovato == 0)
e->next=new;
}
else trovato =1;
}
}
return trovato;
}
e questi errori che non so a cosa sono dovuti ...
In function `int g_add(graph *, int, int, int)':
116: parse error before `new'
119: parse error before `='
120: parse error before `=='
128: parse error before `;'
132: `e' undeclared (first use this function)
132: (Each undeclared identifier is reported only once
132: for each function it appears in.)
145: parse error before `;'
149: confused by earlier errors, bailing out
le strutture sono
typedef struct edge
{
int key;
int dist;
struct edge *next;
} edge;
typedef struct graph
{
int nv; /* numero di vertici del grafo */
edge **adj; /* vettore con le liste delle adiacenze */
} graph;
struct rec
{
int key;
int numero;
char nome [70];
int ore;
int fatturato;
struct rec *next;
};
aiuto :( ...
int g_add(graph *G, int u, int v, int d)
{
edge *new,*e;
int trovato =0;
/*code*/
new = (edge*)malloc(sizeof(edge));
if (new==NULL)
printf("ERRORE: impossibile allocare memoria \n");
else
{
new->key=v;
new->dist=d;
new->next=NULL;
if (G->adj[u] == NULL) /*il nodo u non ha archi */
G->adj[u] = new;
else
{
e=G->adj[u];
if (e->key != v) /*controllo sul primo nodo*/
{
while ((e->next!=NULL) && (trovato == 0))
{
if (e->next->key == v)
{ /*controllo dal secondo nodo*/
trovato =1;
distanza = e->next->dist;
}
else
e=e->next;
}
if (trovato == 0)
e->next=new;
}
else trovato =1;
}
}
return trovato;
}
e questi errori che non so a cosa sono dovuti ...
In function `int g_add(graph *, int, int, int)':
116: parse error before `new'
119: parse error before `='
120: parse error before `=='
128: parse error before `;'
132: `e' undeclared (first use this function)
132: (Each undeclared identifier is reported only once
132: for each function it appears in.)
145: parse error before `;'
149: confused by earlier errors, bailing out
le strutture sono
typedef struct edge
{
int key;
int dist;
struct edge *next;
} edge;
typedef struct graph
{
int nv; /* numero di vertici del grafo */
edge **adj; /* vettore con le liste delle adiacenze */
} graph;
struct rec
{
int key;
int numero;
char nome [70];
int ore;
int fatturato;
struct rec *next;
};
aiuto :( ...