程序如下:
#include"graphics.h"
#include"math.h"
main()
{
int x,y,a,b,h,l,r,driver,mode;
float n=1;
driver=VGA,mode=VGAHI;
initgraph(&driver,&mode,"");
setcolor(GREEN);
setbkcolor(BLACK);
printf("please enter x,y,a,b,h,l,r:");
scanf("%d%d%d%d%d%d%d",&x,&y,&a,&b,&h,&l,&r);
setlinestyle(0,0,1);
rectangle(x-2*r,y-2*h,x,y);
rectangle(x-2*r,y-h,x,y);
line(x+a,y-2*h,x+a,y);
line(x+a,y,x+a+2*l+r,y);
line(x+a+2*l+r,y,x+a+2*l+r,y-h);
line(x+a,y-2*h,x+a+l,y-2*h);
line(x+a+l,y-2*h,x+a+l,y-h);
line(x+a+l,y-h,x+a+2*l+r,y-h);
rectangle(x-2*r,y+b,x,y+b+l);
line(x-2*r,y+b+l,x-2*r,y+b+2*l);
line(x,y+b+l,x,y+b+2*l);
arc(x-r,y+b+2*l,180,0,r);
setlinestyle(2,0,1);
rectangle(60,80,460,380);
setlinestyle(0,0,3);
rectangle(70,90,450,370);
setlinestyle(0,0,1);
line(450,330,250,330);
line(250,330,250,370);
line(330,330,330,370);
line(400,330,400,370);
line(250,350,450,350);
outtextxy(275,340,"Name");
outtextxy(255,360,"baiyang");
outtextxy(340,340,"Class");
outtextxy(335,360,"05010125");
outtextxy(410,340,"Number");
outtextxy(420,360,"18");
while(n!=0)
{
printf("please enter n:");
scanf ("%f",&n);
cleardevice ();
setbkcolor(LIGHTGREEN);
setcolor(1);
x=320,y=300;
setlinestyle(0,0,1);
rectangle(x-2*r*n,y-2*h*n,x,y);
rectangle(x-2*r*n,y-h*n,x,y);
setlinestyle(0,2,1);
rectangle(60,40,460,380);
setlinestyle(0,0,3);
rectangle(70,80,450,370);
setlinestyle(0,0,1);
line(450,330,250,330);
line(250,330,250,370);
line(330,330,330,370);
line(400,330,400,370);
line(250,350,450,350);
outtextxy(275,340,"Name");
outtextxy(255,360,"baiyang");
outtextxy(340,340,"Class");
outtextxy(335,360,"05010125");
outtextxy(410,340,"Number");
outtextxy(420,360,"18");
}
getch ();
closegraph ();
}