|
|
back to boardwhy i got Crash (ACCESS_VIOLATION)??????????????????Can you help me? Posted by arthur 25 Aug 2003 17:01 CODE IS HERE; #include "stdio.h" #include "string.h" long a[401][401]; long n,h,t; long i,j,m; int c[500]; int p[500]; long count=0; void bfs(int i) { int k; for(k=1;k<=n;k++) { if(c[k]==0) { if(a[i][k]==1) { a[i][k]=0; a[k][i]=0; c[k]=1; p[k]=i; bfs(k); } } } } void path(int a1,int a2) { int q[500]; int i=0; while(1) { q[i]=a2; i++; a2=p[a2]; if(a2==a1) break; } printf("%d",i+1); printf(" %d",a1); while(i>0) { printf(" %d",q[i-1]); i--; } printf("\n");
}
void main() { for(i=0;i<401;i++) for(j=0;j<401;j++) a[i][j]=0; scanf("%ld %ld",&n,&m); for(i=0;i<m;i++) { scanf("%ld %ld",&h,&t); a[h][t]=1; a[t][h]=1; } for(i=1;i<=n;i++) c[i]=0;
c[1]=1; bfs(1);
for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) if(a[i][j]==1) { count++; } } printf("%ld\n",count); for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) if(a[i][j]==1) { path(i,j); } }
} Re: why i got Crash (ACCESS_VIOLATION)??????????????????Can you help me? I have same problem and increased answer's array. got AC Re: why i got Crash (ACCESS_VIOLATION)??????????????????Can you help me? Try this 7 8 1 2 2 6 1 6 4 6 4 3 3 5 5 6 3 7 |
|
|