我知道這可能是一個非常簡單的修復,但我很難找到我的錯誤是什麼,也沒有任何我在網上查過的帖子能夠幫我。我得到了關於線路的錯誤。下面的代碼:錯誤:沒有匹配函數調用'在線'
#include <iostream>
bool online(int a, int network[a][a]) {
/*post condition: returns true if every switch in a network is of even degree. Otherwise, returns false.*/
int switches;
for(int x=0; x < a; x++) {
switches = 0;
for(int y=0; y < a; y++)
if(network[x][y])
switches += 1;
if(switches & 1)
return 0;
}
return 1;
}
int main() {
int arrayOne[6][6] =
{
{0,1,1,0,0,0},
{1,0,0,1,0,0},
{1,0,0,1,0,0},
{0,1,1,0,1,1},
{0,0,0,1,0,1},
{0,0,0,1,1,0}
};
int arrayTwo[8][8] =
{
{0,1,1,0,0,0,0,0},
{1,0,0,1,0,0,0,0},
{1,0,0,1,0,0,0,0},
{0,1,1,0,1,0,0,0},
{0,0,0,1,0,1,1,0},
{0,0,0,0,1,0,0,1},
{0,0,0,0,1,0,0,1},
{0,0,0,0,0,1,1,0}
};
std::cout << online(6, arrayOne) << std::endl;
std::cout << online(8, arrayTwo) << std::endl;
}
我得到的錯誤'陣列具有不完整的元素類型爲int「[]」',是的,意圖是返回false,如果有任何行奇數 – Dbz
請只用語言標記您的文章你正在使用。我將它編輯爲'C++',如果您使用的是其他語言,並且我誤讀了您的帖子,請刪除'C++'標籤,並僅使用您正在使用的特定語言。 – mcmonkey4eva
我仍然在同一個地方得到相同的錯誤。 – Dbz