0
之前預期爲不合格id,但我沒看過以前的答案,但他們都沒有解釋爲什麼我得到這個錯誤。錯誤:如果
這是我的錯誤代碼。它發生在「if(pathID == 2 ...)」和每個if語句之後。
void add_path(int a,int b, int current_step,int pathID){
if(pathID == 0){
path[current_step] = new step(a,b,"Filled A",path[current_step]);
}
if(pathID == 1)
path[current_step] = new step(a,b,"Filled B",path[current_step]);
}
if(pathID == 2){
path[current_step] = new step(a,b,"Empty A",path[current_step]);
}
if(pathID == 3){
path[current_step] = new step(a,b,"Empty B",path[current_step]);
}
if(pathID == 4){
path[current_step] = new step(a,b,"Pour B to A",path[current_step]);
}
if(pathID == 5){
path[current_step] = new step(a,b,"Pour A to B",path[current_step]);
}
}
所有這些代碼的目的是要添加到數組中給定位置的鏈表。 pathID傳入並告訴它執行了什麼操作,所以我們知道我們知道要添加到鏈接列表中。
在程序的後面,我使用該鏈表來確定採取了哪些操作。我仍然需要使它成爲一個雙向鏈表,因此它不會反向打印,但這是另一個問題。
你在'if(pathID == 1)'後忘了''''。 –
投票由於簡單的印刷錯誤而作爲離題進行投票。 – Downvoter