# 请教一个C语言图形化编程的问题

0

``` #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;```

0

```for (int i = 1; i <= 3; i++)
for (int j = 1; j <= 3; j++)
{
fillcircle(40+3*i*LEN,  40+3*j*LEN, 2);
}```

0

int x[3] = { 3, 9, 15 };

for ( int i = 0; i < 3; ++i )
{
fillcircle( 40 + x[0] * LEN, 40 + x[i] * LEN, 2 );
fillcircle( 40 + x[1] * LEN, 40 + x[i] * LEN, 2 );
fillcircle( 40 + x[2] * LEN, 40 + x[i] * LEN, 2 );
}

glimix | 园豆：154 (初学一级) | 2015-10-20 16:25

您需要登录以后才能回答，未注册用户请先注册