国际棋盘c语言编程,精!!!C语言实现国际棋盘.docx

#includevoidConPrint(char*CharBuffer,intlen);

voidConPrintAt(intx,inty,char*CharBuffer,intlen);

voidgotoXY(intx,inty);

voidClearConsole(void);

voidClearConsoleToColors(intForgC,intBackC);

voidSetColorAndBackground(intForgC,intBackC);

voidSetColor(intForgC);

voidHideTheCursor(void);

voidShowTheCursor(void);

intmain(intargc,char*argv[])

{inti=0,j=0;

HideTheCursor();

ClearConsoleToColors(15,2);

for(i=0;i<8;i++)

for(j=0;j<8;j++)

{if(i%2==0)

{if(j%2==0)

{SetColorAndBackground(15,15);

ConPrintAt(i,j,"\n",1);}

else

{SetColorAndBackground(1,16);

ConPrintAt(i,j,"\n",1);} //红色为重点

}

else

{if(j%2!=0)

{SetColorAndBackground(15,15);

ConPrintAt(i,j,"\n",1);}

else

{SetColorAndBackground(1,16);

ConPrintAt(i,j,"\n",1);}

}

}

SetColorAndBackground(7,1);

return0;

}

voidClearConsoleToColors(intForgC,intBackC)

{

WORDwColor=((BackC&0x0F)<<4)+(ForgC&0x0F);

HANDLEhStdOut=GetStdHandle(STD_OUTPUT_HANDLE);

COORDcoord={0,0};

DWORDcount;

CONSOLE_SCREEN_BUFFER_INFOcsbi;

SetConsoleTextAttribute(hStdOut,wColor);

if(GetConsoleScreenBufferInfo(hStdOut,&csbi))

{

FillConsoleOutputCharacter(hStdOut,(TCHAR)32,csbi.dwSize.X*csbi.dwSize.Y,coord,&count);

FillConsoleOutputAttribute(hStdOut,csbi.wAttributes,csbi.dwSize.X*csbi.dwSize.Y,coord,&count);

SetConsoleCursorPosition(hStdOut,coord);

}

}

voidClearConsole()

{

HANDLEhStdOut=GetStdHandle(STD_OUTPUT_HANDLE);

COORDcoord={0,0};

DWORDcount;

CONSOLE_SCREEN_BUFFER_INFOcsbi;

if(GetConsoleScreenBufferInfo(hStdOut,&csbi))

{

FillConsoleOutputCharacter(hStdOut,(TCHAR)32,csbi.dwSize.X*csbi.dwSize.Y,coord,&count);

FillConsoleOutputAttribute(hStdOut,csbi.wAttributes,csbi.dwSize.X*csbi.dwSize.Y,coord,&count);

SetConsoleCursorPosition(hStdOut,coord);

}

}

voidgotoXY(intx,inty)

{

COORDcoord={x,y};

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);

}

voidSetColor(intForgC)

{

WORDwColor;

HANDLEhStdOut=GetStdHandle(STD_OUTPUT_HANDLE);

CONSOLE_SCREEN_BUFFER_INFOcsbi;

if(GetConsoleScreenBufferInfo(hStdOut,&csbi))

{

wColor=(csbi.wAttributes&0xF0)+(ForgC&0x0F);

SetConsoleTextAttribute(hStdOut,wColor);

}

}

voidSetColorAndBackground(intForgC,intBackC)

{

WORDwColor=((BackC&0x0F)<<4)+(ForgC&0x0F);;

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),wColor);

}

voidConPrint(char*CharBuffer,intlen)

{

DWORDcount;

WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),CharBuffer,len,&count,NULL);

}

voidConPrintAt(intx,inty,char*CharBuffer,intlen)

{

DWORDcount;

COORDcoord={x,y};

HANDLEhStdOut=GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleCursorPosition(hStdOut,coord);

WriteConsole(hStdOut,CharBuffer,len,&count,NULL);

}

voidHideTheCursor()

{

CONSOLE_CURSOR_INFOcciCursor;

HANDLEhStdOut=GetStdHandle(STD_OUTPUT_HANDLE);

if(GetConsoleCursorInfo(hStdOut,&cciCursor))

{

cciCursor.bVisible=FALSE;

SetConsoleCursorInfo(hStdOut,&cciCursor);

}

}

voidShowTheCursor()

{

CONSOLE_CURSOR_INFOcciCursor;

HANDLEhStdOut=GetStdHandle(STD_OUTPUT_HANDLE);

if(GetConsoleCursorInfo(hStdOut,&cciCursor))

{

cciCursor.bVisible=TRUE;

SetConsoleCursorInfo(hStdOut,&cciCursor);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值