C++;输入回路给出;流程结束,退出代码为11“;错误 以下是我的C++代码的开始。我希望能够输入5个输入,并将它们存储在向量中。但是,代码在双数组元素访问时中断。我如何修复它,为什么它会断裂?我在IDE(CLion)上遇到的错误是“找不到

C++;输入回路给出;流程结束,退出代码为11“;错误 以下是我的C++代码的开始。我希望能够输入5个输入,并将它们存储在向量中。但是,代码在双数组元素访问时中断。我如何修复它,为什么它会断裂?我在IDE(CLion)上遇到的错误是“找不到,c++,arrays,multidimensional-array,clion,C++,Arrays,Multidimensional Array,Clion,C++;输入回路给出;流程结束,退出代码为11“;错误 以下是我的C++代码的开始。我希望能够输入5个输入,并将它们存储在向量中。但是,代码在双数组元素访问时中断。我如何修复它,为什么它会断裂?我在IDE(CLion)上遇到的错误是“找不到运算符[]” #包括 #包括 #包括 #包括 #包括 #包括 使用std::cin; 使用std::cout; 使用std::endl; 使用std::setprecision; 使用std::sort; 使用std::streamsize;

C++;输入回路给出;流程结束,退出代码为11“;错误

以下是我的C++代码的开始。我希望能够输入5个输入,并将它们存储在向量中。但是,代码在双数组元素访问时中断。我如何修复它,为什么它会断裂?我在IDE(CLion)上遇到的错误是“找不到运算符[]”

#包括
#包括
#包括
#包括
#包括
#包括
使用std::cin;
使用std::cout;
使用std::endl;
使用std::setprecision;
使用std::sort;
使用std::streamsize;
使用std::string;
使用std::vector;
int main(){
向量输入向量;
int x;
while(cin>>x&&inputVec.size()<5){
输入向量推回(x);

cout
四分位数[i][j]
不存在yet@LightnessRacesinOrbit它不是定义了3行吗?从问题行开始。“向量四分位数(4);”
向量四分位数(4);
将使4
向量
s和无
整数
进入这些
向量
s。你想要沿着
向量四分位数(4,向量)的行的东西吗(quartileSize));
更好的措辞:想想
向量四分位数(4);
就像你想
整数四分位数[4][0]第二维度的大小尚未确定。内部
for
循环使用
j
作为计数器,但条件检查
i
。循环要么根本不执行,要么无休止地执行(这可能会导致分段故障/SIGSEGV/信号11)。
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;

using std::sort;
using std::streamsize;
using std::string;
using std::vector;

int main () {
    vector<int> inputVec;
    int x;
    while (cin >> x && inputVec.size() < 5) {
        inputVec.push_back(x);
        cout << inputVec.size() << endl;
    }
    sort(inputVec.begin(), inputVec.end());
    cout << "before if 1" << endl;
    typedef vector<double>::size_type vec_sz;
    vec_sz size = inputVec.size();
    cout << "before if 3" << endl;
    if (size < 4) {
        cout << "too few inputs";
    } else {
        cout << "calculating quartiles" << endl;
        int quartileSize = size / 4;
        int leftOvers = size - quartileSize * 4;
        int count = 0;
        vector<vector<int>> quartiles(4);
        for (int i = 0; i < 3; i++) {
            for (int j = 0; i < quartileSize; j++) {
                quartiles[i][j] = inputVec[count++];
            }
        }