1
所以我必須做出一個名爲history[][]
,其中history[i]
存儲所有目前參與實驗i
科目,並history[i][j]
包含一個字符串,列出所有的字符串2 d陣列這個特定主題已成爲其中一部分的實驗。問題是,我必須使用int* numsubjects
,這是一個整數數組,告訴我在實驗i
中有多少個主題。但是,numsubjects
的內容應該能夠移動,因爲主題可以移動到其他實驗中。我不知道如何去做這件事。我不能使用vector
,dequeue
或list
。當只有一個實驗字符串動態二維數組,其中第二尺寸可以改變
experiments = 0;
numsubjects = new int[experiments+1];
numsubjects[experiments] = n;
history = new string*[0];
for(int j = 0; j < n; j++) {
history[0] = new string[j];
history[0][j] = "0";
}
上面的代碼初始化一切,實驗0。我需要一種方法來創造歷史不知何故與它numsubjects。
你到目前爲止已經嘗試了什麼,請顯示一些代碼 – 3stud1ant3
除非這是針對禁止使用標準容器的任務,請嘗試[std :: vector](http://en.cppreference.com/w/) cpp/container/vector)或[std :: map](http://en.cppreference.com/w/cpp/container/map) – 0x5453