|
|
вернуться в форумdrive me mad!!why Compilation error !!?? #include<iostream> #include<cstdlib> #include<cstdio> using namespace std; struct list{ int num[100]; }; struct graph{ int used; int degree; int parent; struct list* p; }; void initialize(struct graph* g,short int n){ for(int i=1;i<n+1;i++){ g[i].used=0; g[i].degree=0; g[i].parent=0; struct list* p=new list; int number; g[i].p=p; do{ scanf("%d",&number); if(number!=0){ g[i].p->num[g[i].degree++]=number; } }while(number!=0); } } int findzero(struct graph* g,int n) { for(int i=1;i<n+1;i++) if(g[i].parent==0&&(!g[i].used)){ g[i].used=1; return i; } } void topsort(struct graph* g,int n) { for(int i=1;i<n+1;i++){ int v=findzero(g,n);
printf("%d ",v); for(int j=0;j<g[v].degree;j++){ g[g[v].p->num[j]].parent--; } } printf("\n"); } void calparent(struct graph* g,int n) { for(int i=1;i<n+1;i++) for(int j=0;j<g[i].degree;j++) g[g[i].p->num[j]].parent++; } int main() { int n; scanf("%d",&n); struct graph g[n+1]; initialize(g,n); calparent(g,n); topsort(g,n); return 0; } ---------------------------- i got right in my own ide, but in ural it said compilation error!!__why????? Re: drive me mad!!why Compilation error !!?? when you submit code you can set option "Reply" in "To this E-Mail address"
Re: drive me mad!!why Compilation error !!?? many thx,it works!! |
|
|