我收到上述錯誤。我在C編碼並使用標準的gcc編譯器(命令窗口)。這是我的代碼中有問題的部分。我沒有看到任何錯誤,也許是我的眼睛累了看同樣的事情預計';'之前的'{'令牌C代碼
LEADER *call_leader(double st1, double st2, double incentive, double pdis)
{
LEADER *leader= (LEADER *)malloc(sizeof(LEADER));
double shortest = MIN(st1, st2) ; //shortest station
if (shortest == st1 && s1 != 0){ //no congestion
leader->price1 = p_max;
leader->price2 = p_max;
}
if (shortest == st2 && s2 != 0){ //no congestion
leader->price1 = p_max;
leader->price2 = p_max;
}
if (shortest == st1 && s1 == 0){ //congestion at station 1
if (s2 != 0){ // no congestion at station 2, try to route
leader->price1 = p_max;
double cost_1 = shortest*pdrive + p_max;
double p2 = cost1 - st2*pdrive - (sqrt(pow((st2 - st1),2)))*pdis - incentive;
if (p2 >= p_min){
leader->price2 = p2;
}else{
leader->price2 = p_min;
}
}
else if (s2 == 0){
if (r1 >= r2){ // st1 less congestion
leader-> price1 = p_max;
}
Problematic Line => else (r1 < r2) { //try to route s2
leader -> price1 = p_max;
double cost_1 = shortest*pdrive + p_max;
double p2 = cost1 - st2*pdrive - (sqrt(pow((st2 - st1),2)))*pdis - incentive;
if (p2 >= p_min){
leader->price2 = p2;
}
else{
leader->price2 = p_min;
}
}
}
}
'else'不採用條件語句,你可能意味着'else if(r1
birryree
我修復了你的格式。但爲了將來的參考,儘量避免在代碼塊中使用製表符,因爲它們可能會弄亂格式。 – Mysticial