我感到困惑與下面的代碼段的時間複雜度....時間以下代碼的複雜性..?
i = 0
//first row
if(board[i][0] == win && board[i][1] == win && board[i][2] == win)
return win;
//second row
if(board[i+1][0] == win && board[i+1][1] == win && board[i+1][2] == win)
return win;
//third row
if(board[i+2][0] == win && board[i+2][1] == win && board[i+2][2] == win)
return win;
//first col
if(board[0][i] == win && board[1][i] == win && board[1][i] == win)
return win;
//second col
if(board[0][i+1] == win && board[1][i+1] == win && board[2][i+1] == win)
return win;
//third col
if(board[0][i+2] == win && board[1][i+2] == win && board[2][i+2] == win)
return win;
//first diag
if(board[i][i] == win && board[i+1][i+1] == win && board[i+2][i+2] == win)
return win;
//second diag
if(board[i+2][i] == win && board[i+1][i+1] == win && board[i][i+2] == win)
return win;
我是一個循環的一部分還是隻是總是0? – BrandonAGr 2011-03-24 04:55:35