#include
#include
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");
scanf("%d", &rect->ymin);
printf("Enter the y-max:\n");
scanf("%d", &rect->ymax);
//input the color
printf("Enter your color:\n");
scanf("%d", &color);
//call our paint function
FillRectangle(rect, color);
return 0;
}