资源简介
需要在turboc下运行,需要在turboc下运行,需要在turboc下运行,
计算机图形学,种子填充算法,用c编写,要在tc下运行
tc目录:c:\tc.可以在main()中更改
代码片段和文件信息
#include
#include
#include
#include
#define size 1000
#define color 4
typedef struct
{
int xy;
}point;
typedef struct
{
point *base*top;
int stackSize;
}stack;
void initStack(stack *s)
{
s->stackSize=size;
s->base=(point *)malloc(sizeof(point)*s->stackSize);
if(!s->base)
printf(“init stack error!“);
s->top=s->base;
}
int getTop(stack *spoint *p)
{
if(s->top==s->base)
return 0;
p->x=(s->top-1)->x;
p->y=(s->top-1)->y;
return 1;
}
int pop(stack *spoint *p)
{
if(s->base==s->top)
return 0;
s->top--;
p->x=s->top->x;
p->y=s->top->y;
return 1;
}
int push(stack *spoint *p)
{ point *temp=NULL;
if(s->top-s->base>=s->stackSize)
{
temp=(point *)realloc(s->basesizeof(point)*(s->stackSize+100));
if(!temp)
{
printf(“memory is not enough!\n“);
getch();
exit(0);
}
s->stackSize+=100;
s->top=(s->top-s->base)+temp;
s->base=temp;
}
s->top->x=p->x;
s->top->y=p->y;
s->top++;
return 1;
}
int scan(stack *s)
{
int up=1down=1;
point p temp;
while(pop(s&p)==1)
{
while(getpixel(p.x+1p.y)==0)
p.x++;
while(getpixel(p.xp.y)==0)
评论
共有 条评论