C语言 矩形填充算法

来源:百度知道 编辑:UC知道 时间:2024/06/23 00:03:45
下面是C语言的矩形填充算法,请问主函数怎么编写?参数怎么传递?给个例子能实现的,谢谢
#include "stdio.h"
#include "graphics.h"
typedef strut
{
int xmin,ymax,ymin,ymax;
}Rectangle;
void FillRectangle(Rectangle *rect,int color)
{
int x,y;
for(y = rect->ymin;y<=rect->ymax;y++)
for(x = rect->xmin;x<=rect->xmax;x++);
putpixel(x,y,color);
}/* end of FillRectangle() */

#include <stdio.h>
#include <graphics.h>

typedef struct {
int xmin, xmax, ymin, ymax;
} Rectangle;

void FillRectangle(Rectangle *rect, int color) {
int x = 0, y = 0;
for (y = rect->ymin; y <= rect->ymax; y++)
for (x = rect->xmin; x <= rect->xmax; x++) //这里有个分号,应该去掉。
putpixel(x, y, color);
}/* end of FillRectangle() */

int main() {

//declare our color
int color = 0;

//declare our rectangle
Rectangle *rect = (Rectangle *) malloc(sizeof(Rectangle));

if(NULL == rect )
{
printf("allocation memory failed!\n");
return 1;
}
//input the scope
printf("Enter the x-min:\n");
scanf("%d", &rect->xmin);

printf("Enter the x-max:\n");
scanf("%d", &rect->xmax);

printf("Enter the y-min:\n