新手求助,编译报错:segmentation fault(core dump)
  • 板块B3630 排队顺序
  • 楼主hpxx
  • 当前回复2
  • 已保存回复2
  • 发布时间2022/11/25 20:44
  • 上次更新2023/10/27 01:31:18
查看原帖
新手求助,编译报错:segmentation fault(core dump)
753918
hpxx楼主2022/11/25 20:44
#include<iostream>
using namespace std;
struct a{
    int id;
    struct a *next;
};
int N;
int main(){
    cin >> N;
    struct a b[1000001];
    for(int i = 1; i <= N; i++){
        int temp;
        cin >> temp;
        b[i].id = i;
        if(temp == 0){
            b[i].next=NULL;
            continue;
        }
        b[i].next=&b[temp];
    }
    int last;
    struct a *head = &b[last];
    while(head){
        cout << head->id << endl;
        head = head->next;
    }
    return 0;
}
2022/11/25 20:44
加载中...