|
|
вернуться в форумОбщий форумHelp! I've got Crash (ACCESS_VIOLATION)! Why? Послано Borech 25 июл 2003 15:40 #include <iostream.h> const int max_num=100; int N, G[max_num][max_num], color[max_num], sorted[max_num], last_sorted; void DFS_VISIT(int i) { color[i]=1; for(int j=1;G[i][j]!=0;j++) { if (color[G[i][j]]==0) DFS_VISIT(G[i][j]); } color[i]=2; last_sorted++; sorted[last_sorted]=i; } void DFS() { for(int i=1;i<=N;i++) { color[i]=0; } for(int k=1;k<=N;k++) if (color[k]==0) DFS_VISIT(k); } int main() { cin >> N; for(int i=1;i<=N;i++) { int x=1; for(int j=1;x!=0;j++) { cin >> x; G[i][j]=x; } } last_sorted=0; DFS(); for(int j=last_sorted;j>0;j--) cout << sorted[j] << ' '; return 0; } Problem 1022 Послано Borech 25 июл 2003 15:40 |
|
|