0
我想通過作爲向量參數列的數組,但我不知道該怎麼做。我正在使用「矢量」庫。我要發佈一個例子澄清我想:作爲向量參數的數組的列
#include <iostream>
#include <vector>
using namespace std;
//function for get the sum of all the elements of a vector H
double suma(vector<double> H) {
double Sum = 0.0;
for (int i = 0; i < H.size(); i++) {
Sum += H[i];
}
return Sum;
}
int main() {
vector<vector<double> > phi;
phi.resize(10, vector<double> (2,1.0));
cout << suma(phi[][1]) << endl;
}
它不工作:(誰能幫我提前
感謝
我認爲有一些關於數組和向量的真正基本的東西,你不太明白。由於代碼看似不連貫,我不知道如何幫助解決這個問題。 – Almo
你想通過phi中的某個向量嗎? – 4pie0
數組不是表格。它沒有「欄」。目前還不清楚你的意思是什麼...... –