C ++中如何在Excel中将列转换为C ++中的vector?

在下面的代码中,我想validation一些数据。 不过,我不知道如何用csv文件逗号分隔符来做到这一点。 如果我想用一个csv文件中的vector来replace提交{5,0,3,4,6,1}的vectorvector和期望vector{0,0,33,50,0,0} :

……..提交….预期

  1. …….. 5 ……………. 0
  2. ……. 0 …………….. 0
  3. ……. 3 ……………. 33
  4. ……. 4 ……………. 50
  5. ……. 6 ……………. 0
  6. ……… 1 ………… 0

所以基本上我想从csv文件中得到我的载体…其中列提交是我的第一个向量和预期的列是我的第二个向量。 我想处理更多的数据,并将其放置在我的csv文件中,然后将其转换为vector,并将下面代码中提交的和期望的代码replace为具有来自我的csv文件的vector的vector。 有没有办法做到这一点?

int main(){

vector<int> result; vector <string> validate; vector<int> submitted{5,0,3,4,6,1}; vector<int> expected{0,0,33,50,0,0}; for (int j = 0; j < submitted.size(); j++) { for (int i = 0; i <= submitted[j]; i++) { if (round(((1.0 / submitted[j]) * i) * 100) == expected[j]) { validate.push_back("passed"); result.push_back(round(((1.0 / submitted[j]) * i) * 100)); cout << " Result: " << result[j]<<" Expected : " << expected[j]<< " Status: "<< validate[j]<<endl; break; } //if the next greater number than expected, give the last plausible integer else if (round(((1.0 / submitted[j]) * (i+1)) * 100) > expected[j]&&expected[j]!=0&&submitted[j]!=0) { validate.push_back("failed"); result.push_back(round(((1.0 / submitted[j]) * i) * 100)); cout << " Result: " << result[j] << " Expected : " << expected[j] << " Status: " << validate[j]<<endl; break; } else if (expected[j] == 0||submitted[j]==0) { validate.push_back("failed"); result.push_back(0); cout << " Result: " << 0 << " Expected : " << 0 << " Status: " << " passed " << endl; break; } } } return 0;