给你改了改,能A了,你先看一下,有不会的再问我
```cpp
#include<bits/stdc++.h>
using namespace std;
int a[1001][1001],c[1001],r[1001],ans[1001];
int j,top,temp,num,n,m;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
do
{
cin>>j;
if(j!=0)
{
c[i]++;
a[i][j]=1;
r[j]++;
}
}while(j!=0);
}
for(int i=1;i<=n;i++)
{
if(r[i]==0)
{
ans[++top]=i;
}
}
do
{
temp=ans[top];
cout<<temp<<" ";
top--;
num++;
for(int i=1;i<=n;i++)
{
if(a[temp][i]){
r[i]--;
if(r[i]==0) ans[++top]=i;
}
}
}while(top);
return 0;
}
```
by Poole_tea @ 2023-07-12 11:37:24
@[Poole_tea](/user/668379) 哇塞,神犇,感谢您(360度无死角鞠躬感谢)让我给你一个关注吧!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
by WangYouxiu @ 2023-07-12 13:49:30