Chinaunix首页 | 论坛 | 博客
  • 博客访问: 407696
  • 博文数量: 51
  • 博客积分: 2030
  • 博客等级: 大尉
  • 技术积分: 1109
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-15 08:11
文章分类

全部博文(51)

文章存档

2022年(1)

2016年(2)

2015年(1)

2014年(2)

2013年(4)

2011年(9)

2010年(2)

2009年(5)

2008年(14)

2007年(11)

我的朋友

分类: C/C++

2007-07-04 16:03:00

#include "Conio.h"
#include "graphics.h"
#define closegr closegraph
void initgr(void)
{
  int gd=DETECT,gm=0;
  initgraph(&gd,&gm,"");
}

void seedfilling(x,y,fill_color,boundary_color)
int x,y,fill_color,boundary_color;
{
 int c;
 c=getpixel(x,y);
 if((c!=boundary_color)&&(c!=fill_color)) 
 {
  putpixel(x, y, fill_color); /*画点*/
  /*getch(); */
 
   seedfilling(x+1,y, fill_color, boundary_color); 
   seedfilling(x-1,y, fill_color, boundary_color);
   seedfilling(x, y+1, fill_color, boundary_color);
   seedfilling(x, y-1, fill_color, boundary_color);
  }
}
 
void main()
{
 int a,b,color;
 int gd=DETECT , gm;
 int poly[10];
 a=150  ;
 b=140;
 color=9;
 initgraph(&gd , &gm , "");
 poly[0] = 110;       
 poly[1] = 110;
 poly[2] = 200;     
 poly[3] = 105;
 poly[4] = 170;    
 poly[5] = 120;
 poly[6]=150;       
 poly[7]=170;
 poly[8]=110;     
 poly[9]=110;

 printf("Enter fill_color: ");
 scanf("%d",&color);
 while(color>=15)
 {
    printf("Enter error ! please reinput color !\n");
    printf("Enter fill_color: ");
    scanf("%d",&color);
 }
 printf("Enter a and b: ");
 scanf("%d%d",&a,&b);
 while(a>155 || a<145)
 {
    printf("Out range ! please reinput a between 145-155 !\n");
    printf("Enter a: ");
    scanf("%d",&a);
 }
 while(b>155 || b<120)
 {
    printf("Out range ! please reinput b between 120-155 !\n");
    printf("Enter b: ");
    scanf("%d",&b);
 }
 drawpoly(5,poly);
 seedfilling(a,b,color,15); 
 getch();
 closegraph();
}
阅读(3046) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-11-04 19:37:44

可以再发个截图吗