我正在努力解决这个问题。基本上,我必须先阅读一个数字:
int n;
scanf("%d", &n);
然后我必须将 N 个区间读入一个向量:
vector< vector<int> > intervals;
int a, b;
for (int i = 0; i < n; i++) {
scanf("%d %d", &a, &b);
intervals.at(i).at(0) = a;
intervals.at(i).at(1) = b;
}
使用 GDB 调试器,我得到了这个:
3
1 4
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check
Program received signal SIGABRT, Aborted.
0x00007ffff7260c35 in raise () from /lib/libc.so.6
(gdb)
知道我做错了什么吗?谢谢!