这道题就是一道遍历链表的题
我们的指针域就是4 6 0 2 3 5
我们的数据域就是 1 2 3 4 5 6
#include <iostream>
using namespace std;
const int N = 1e6+10;
int ne[N],id;
int n,h; int main()
{cin >> n;for(int i = 1;i<=n;i++){cin >> ne[i];}cin >> h;for(int i = h;i;i=ne[i]){cout << i << " ";}return 0;
}