写37行代码就为了画个围棋棋盘值不值?有更简洁的算法吗?
#include<graphics.h>
#include<conio.h>
#define LEN 30 // 每格间的距离
int main()
{
int x, y;
initgraph(660, 660);
// 背景上色
setcolor(BROWN);
for(y = 0; y < 660; y++)
line(0, y, 660, y);
// 绘制边框
setcolor(BLACK);
line(35, 35, 45+540, 35);
line(35, 45+540, 45+540, 45+540);
line(35, 35, 35, 45+540);
line(45+540, 35, 45+540, 45+540);
for(y = 40; y<=40+LEN*18; y+=LEN)
line(40, y, 40+LEN*18, y);
for(x = 40; x<=40+LEN*18; x+=LEN)
line(x, 40, x, 40+LEN*18);
// 绘制黑点
setfillcolor(BLACK);
fillcircle(40+3*LEN, 40+3*LEN, 2);
fillcircle(40+9*LEN, 40+3*LEN, 2);
fillcircle(40+15*LEN, 40+3*LEN, 2);
fillcircle(40+3*LEN, 40+9*LEN, 2);
fillcircle(40+9*LEN, 40+9*LEN, 2);
fillcircle(40+15*LEN, 40+9*LEN, 2);
fillcircle(40+3*LEN, 40+15*LEN,2);
fillcircle(40+9*LEN, 40+15*LEN,2);
fillcircle(40+15*LEN, 40+15*LEN,2);
getch();
closegraph();
return 0;