Mam taki kod:
#include <stdio.h>
const int FALSE = 0;
const int TRUE = 1;
typedef int BOOL;
struct droga
{
int miasto;
int uzywana;
};
void Zeruj(struct droga ***mapa, int ilosc)
{
int i, j;
for(i = 0; i < ilosc; i++)
for(j = 0; j < ilosc; j++)
mapa[i][j] = NULL;
}
BOOL Szukaj(struct droga ***mapa, int ilosc, int numer)
{
int i;
if (numer >= ilosc)
return TRUE;
for (i = 0; i < ilosc; i++)
{
if (mapa[numer][i])
{
if (mapa[numer][i]->uzywana == 0)
{
mapa[numer][i]->uzywana = 1;
mapa[numer][i]->miasto = numer;
mapa[i][numer]->uzywana = 1;
mapa[i][numer]->miasto = numer;
if (!Szukaj(mapa, ilosc, numer+1))
{
mapa[numer][i]->uzywana = 0;
mapa[numer][i]->miasto = 0;
mapa[i][numer]->uzywana = 0;
mapa[i][numer]->miasto = 0;
}
else
{
return TRUE;
}
}
}
}
return FALSE;
}
int main()
{
int n ,m;
scanf("%d %d", &n, &m);
struct droga* mapa[n][n];
Zeruj(mapa, n);
int i;
for (i = 0; i < m; i++)
{
int a, b;
scanf("%d %d", &a, &b);
struct droga *temp = (struct droga*)malloc(sizeof(struct droga));
temp->uzywana = FALSE;
temp->miasto = 0;
mapa[a][b] = temp;
mapa[b][a] = temp;
}
if (m < n)
printf("NIE");
if (Szukaj(mapa, n, 0))
printf("TAK");
else
printf("NIE");
return 0;
}
Jednak gdy go kompiluję dostaję takie błędy:
zadanie.c: In function 'main':
zadanie.c warning: passing argument 1 of 'Zeruj' from incompatible pointer type
zadanie.c warning: incompatible implicit declaration of built-in function 'malloc'
zadanie.c warning: passing argument 1 of 'Szukaj' from incompatible pointer type
Jak mam przekazać zmienną mapa do funkcji Zeruj() i Szukaj(), próbowałem już na różne sposoby, ale nie wychodzi mi.