|
|
вернуться в форумHelp, I don't know wtf is wrong with my code Послано Oscar 29 июл 2003 08:30 Hello guys, This problem doesn't seem to be so complicated, and my code works find in all the cases that I have tried, can anyone give me some extreme cases or take a look at the source? Thanks in advanced Oscar //------------------------------------------------------------ #include <stdio.h> #include <string.h> short tree[101][101], list[101], n, i, j,l; void inicializa(void); void lee_valores(void); void hazlo(int v); void main(void) { scanf("%d", &n); inicializa(); lee_valores(); for (i=1; i<n+1; i++){ if (!visitado[i]) hazlo(i); } } void hazlo(int v) { visitado[v]=1; for (j=n; j>0; j--) if ((tree[j][v]) && (!visitado[j])) hazlo(j); printf("%d ", v); } void inicializa(void) { memset(tree, 0, sizeof(tree)); memset(list, 0, sizeof(list)); memset(visitado, 0, sizeof(visitado)); } void lee_valores(void) { int temp; for(i=1; i<n+1; i++){ for(j=1; j<n+1; j++){ scanf("%d", &temp); if (temp == 0) break; tree[i][temp] = 1; } } } |
|
|