本帖最后由 森林木 于 2016-8-27 20:44 编辑
先来看看改进的地方:在1.0.1版本中,啊哈C的运行是通不过的;为什么呢?举个栗子:
(因为楼主太懒,所以头文件就不写了)
[mw_shl_code=c,true](因为楼主太懒,所以头文件就不写了)
int main()
{
printf("111");
Sleep(1000);
system("clear");
printf("222");
system("pause");
return 0;
}[/mw_shl_code]
这样是可以运行的,对吗?
这样呢:
[mw_shl_code=c,true]int main()
{
printf("111");
Sleep(1000);
system("clear");
printf("222");
system("pause");
return 0;
}[/mw_shl_code]
你会发现,啊哈C屏幕会出现这样一句话:
————————————————————
'clear' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
————————————————————
这是为什么呢?
因为啊哈C没有Linux,谁然语法对了,但是内部还是会错的;
所以,我们把
[mw_shl_code=c,true]system("clear");[/mw_shl_code]
改成了
[mw_shl_code=c,true]system("cls");[/mw_shl_code]
完整源代码如下:
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
#define N 15
int chessboard[N + 1][N + 1] = { 0 };
int whoseTurn = 0;
void initGame(void);
void printChessboard(void);
void playChess(void);
int judge(int, int);
int main(void)
{
initGame();
while (1)
{
whoseTurn++;
playChess();
}
return 0;
}
void initGame(void)
{
char c;
printf("-------------GOMOKU 1.0.2-------------\n");
printf(" Box Company \n");
printf("Press any key to enter the game... \n");
getch();
system("cls");
printf("Do you want to play(Y/N)?\n");
c=getch();
if ('y' != c && 'Y' != c)
exit(0);[/mw_shl_code]
我只开40行,你来揍我呀
|