#include<graphics.h>
#include<conio.h>
#pragma warning(disable:4996)
int main()
{
int step = 50;
initgraph(500, 500); //初始化 500 * 500 的画布
setbkcolor(RGB(210,180,140)); //设置背景色为黄色
cleardevice(); //用背景色清空画布
int i, j;
for (i = 1; i <= 8; i++)
{
for (j = 1; j <= 8; j++)
{
if ((i + j) % 2)
{
setfillcolor(BLACK);
solidrectangle(i * step, j * step, (i + 1) * step, (j + 1) * step); //绘制黑色砖块
}
else
{
setfillcolor(WHITE);
solidrectangle(i * step, j * step, (i + 1) * step, (j + 1) * step); //绘制白色砖块
}
}
}
getch();
closegraph();
return 0;
}
绘制国际象棋棋盘参考代码
最新推荐文章于 2025-03-26 04:09:52 发布