求助玄学错误
查看原帖
求助玄学错误
727411
invisible_person楼主2023/1/16 19:51

以下这段看上去很正常,本该输出 22 的代码却输出了 00 并且还在本地 RE 了。求原因。

#include <bits/stdc++.h>
using namespace std;

int tot = 1;
vector<int> v;

void init() {
	v.push_back(0), v.push_back(0);
}

int new_node() {
	tot++;
	v.push_back(0);
	return tot;
}

signed main() {
	init();
	v[1] = new_node();
	cout << v[1] << endl;
	return 0;
}
``
2023/1/16 19:51
加载中...