📄 例4-21.c
字号:
/* Note:Your choice is C IDE */
#include <stdio.h>
#include <graphics.h>
main()
{
int graphdriver=VGA,graphmode=VGAHI,x,color;
struct fillsettingstype save;
char savepattern[8];
char fillpattern[13][40]={{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x20,0x00,0x00,0x00,0x20,0x00,0x00},
{0x20,0x00,0x20,0x00,0x80,0x00,0x08,0x00},
{0x20,0x02,0x80,0x08,0x20,0x02,0x80,0x08},
{0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11},
{0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11},
{0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0x44},
{0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,0xee},
{0xbb,0xee,0xbb,0xee,0xbb,0xee,0xbb,0xee},
{0xdf,0xff,0x7f,0xf7,0xdf,0xfd,0x7f,0xf7},
{0xdf,0xff,0xfd,0xff,0x7f,0xff,0xf7,0xff},
{0xff,0xff,0xff,0xff,0xff,0xfd,0xff,0xff},
{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}};
initgraph(&graphdriver,&graphmode,"");
getfillsettings(&save);
setcolor(WHITE);
rectangle(0,0,539,399);
for(x=15;x<476;x=x+75)
{
rectangle(x,20,x+60,190); /* 画屏上方的框 */
rectangle(x,210,x+60,380); /* 画屏下方的框 */
}
color=-1;
for(x=16;x<476;x=x+75)
{
color=color+1;
setfillpattern(fillpattern[color],color+1);
floodfill(x,21,WHITE); /* 对上方7个框用相应图模和颜色填充 */
}
for(x=16;x<401;x=x+75)
{
color=color+1;
setfillpattern(fillpattern[color],color+1);
floodfill(x,220,WHITE); /* 对下方7个框用相应图模和颜色填充 */
}
setfillstyle(save.pattern,save.color); /*恢复原填充模式和颜色 */
getch();
closegraph();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -