例4-21.c

来自「王为青 刘变红 编著《C语言高级编程及实例剖析》源代码」· C语言 代码 · 共 47 行

C
47
字号
/* 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 + =
减小字号Ctrl + -
显示快捷键?