實現三子棋程式
#define _crt_secure_no_warnings
#include
#include
#include
#include
intmenu()
#define max_row 3
#define max_col 3
void
init
(char chessboard[max_row]
[max_col]
)//}
srand((
unsigned
int)
time(0
));memset
(chessboard,
' ', max_row*max_col*
sizeof
(char))
;}void
print
(char chessboard[max_row]
[max_col]
)printf
("+---+---+---+\n");
}void
playermove
(char chessboard[max_row]
[max_col])if
(chessboard[row]
[col]
!=' '
) chessboard[row]
[col]
='x'
;break;}
}void
computermove
(char chessboard[max_row]
[max_col]
) chessboard[row]
[col]
='0'
;break;}
}//intisfull
(char chessboard[max_row]
[max_col])}
}return1;
}//返回值表示遊戲的狀況
//1,返回x表示玩家勝利
//2,返回o表示電腦勝利
//3,返回『 』表示還未分勝負
//4,返回q表示和棋
char
cheak
(char chessboard[max_row]
[max_col])}
//2.再檢查所有列
for(
int col =
0; col < max_col; col++)}
//再檢查對角線
if(chessboard[0]
[0]!=
' '&&chessboard[0]
[0]== chessboard[1]
[1]&& chessboard[0]
[0]== chessboard[2]
[2])
if(chessboard[0]
[2]!=
' '&&chessboard[0]
[2]== chessboard[1]
[1]&& chessboard[0]
[2]== chessboard[2]
[0])
//判定是否和棋if(
isfull
(chessboard)
)return
' ';
}void
game()
;init
(chessboard)
;//7.回到2繼續執行
char winner =
' ';
while(1
)//5.電腦進行落子
computermove
(chessboard)
;//6.檢查遊戲是否結束
第四節 陣列(二)
實現掃雷程式 define crt secure no warnings include include include include define max row 9 define max col 9 define mine count 10 intmenu void init char sho...
第四節 單鏈表 一
變數的三要素 名字,記憶體位址,值 變數的左值,右值 左值指變數的記憶體位址 右值 值 在賦值表示式中,賦值號左邊需要左值,右邊需要右值 如a a 100 指標變數 指標變數的右值本身又是乙個左值。個人上課未理解的點 頭指標 指向第乙個結點的指標,鍊錶的定義 struct node 頭指標的實現 s...
第四節 資料降維案列
import pandas as pd from sklearn.decomposition import pca 讀取表 prior pd.read csv r e 360downloads software 降維案列資料 order products prior.csv products pd....