#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <math.h>
#include <graphics.h>
#include <bios.h>
#include <stdlib.h>
#define PI 3.14159
void moon()
{
int x=50,y=50,n=30;
setcolor(YELLOW);
setfillstyle(1,YELLOW);
ellipse(x,y,0,360,n,n);
ellipse(x+n/2,y,90,270,n,n);
floodfill(x-n+3,y,YELLOW);
setcolor(BLACK);
circle(x,y,n);
circle(x+n/2,y,n);
}
void star(int x, int y)
{
int i,a;
int n=5;
int x1[5],y1[5],x2[5],y2[5];
setcolor(YELLOW);
for (i=0;i<5;i++)
{
x1[i]=x+n*cos(i*72*PI/180);
y1[i]=y+n*sin(i*72*PI/180);
x2[i]=x+n/2*cos(i*72*PI/180+PI/5);
y2[i]=y+n/2*sin(i*72*PI/180+PI/5);
}
for(i=0;i<5;i++)
{
a=i+1;
if(a>4) a=0;
line(x1[i],y1[i],x2[i],y2[i]);
line(x2[i],y2[i],x1[a],y1[a]);
}
}
void drawstar()
{
int a[]={70,250,190,400,150};
int b[]={43,27,38,79,90},i;
setfillstyle(1,14);
for(i=0;i<5;i++)
{
star(a[i],b[i]);
floodfill(a[i],b[i],YELLOW);
}
}
void starflower()
{
int i=0,j,n=60,n1=2;
int x=200,y=200,size=100;
int cover=0;
int delay1=5000;
int wid,hei;
int px,py;
int color=9;
while(!kbhit())
{
if(i<size)
{
for(j=0;j<n;j++)
{
px=x+i*cos(j*360/n*PI/180);
py=y+i*sin(j*360/n*PI/180);
putpixel(px,py,rand()%16);
putpixel(px-1,py,color);
putpixel(px,py+1,color);
putpixel(px+1,py-1,YELLOW);
putpixel(px,py-1,YELLOW);
putpixel(px+1,py,RED);
putpixel(px+1,py+1,RED);
}
}
if(i>size && cover<size)
{
setcolor(BLACK);
circle(x,y,cover++);
delay1=1000;
}
if(cover==size)
{
i=0;
x=50+rand()%550;
y=rand()%400;
cover=0;
color=rand()%16;
size=50+rand()%250;
delay1=10000;
clearviewport();
drawstar();
moon();
}
i+=n1;
delay(delay1);
}
}
main()
{
int i,j,k;
int gdriver = DETECT, gmode;
registerbgidriver(EGAVGA_driver);
initgraph(&gdriver,&gmode,"");
drawstar();
moon();
starflower();
}
----------------解决方案--------------------------------------------------------