帮忙看看第一句错在哪
#include<graphics.h> #include<math.h>
#include<bios.h>
#include<stdio.h>
#define PI 3.1415926
float th=PI/180;
struct canshu
{
int x;
int y;
int r;
int theta;
}canshu;
void main()
{
FILE *fp;
int k1,k2;
int x0,y0,r,theta;
void save();
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
printf("if you want to input,please press y,if you want to call saved file,press anykey\n");
if(getchar()=='y')
{
printf("please input the x0,y0,r,theta:\n");
scanf("%d%d%d%d",&x0,&y0,&r,&theta);
canshu.x=x0;canshu.y=y0;canshu.r=r;canshu.theta=theta;
save();
}
else
{
fp=fopen("d:\\canshu_list","rb");
fread(&canshu,sizeof(struct canshu),1,fp);
x0=canshu.x;y0=canshu.y;r=canshu.r;theta=canshu.theta;
fclose(fp);
}
cleardevice();
setbkcolor(BLUE);
star(x0,y0,r,theta);
while(1)
{
k1=k2=bioskey(0);
k1=k1&0xff;
k2=k1? 0:k2>>8;
switch(k2)
{
case 72:
cleardevice();
theta+=90;
star(x0,y0,r,theta);
break;
case 80:
cleardevice();
theta-=90;
star(x0,y0,r,theta);
break;
}
if(k1==13) break;
}
}
star(int x,int y,int r,int theta)
{
int r0=r*sin(18*th)/cos(36*th);
int i,color;
int x1[6],y1[6],x2[6],y2[6];
for(i=0;i<6;i++)
{
x1[i]=x+r*cos((theta+i*72)*th);
y1[i]=y-r*sin((theta+i*72)*th);
x2[i]=x+r0*cos(((theta-36)+i*72)*th);
y2[i]=y-r0*sin(((theta-36)+i*72)*th);
}
setcolor(YELLOW);
circle(x1[0],y1[0],5);
setfillstyle(1,GREEN);
floodfill(x1[0],y1[0],YELLOW);
setcolor(RED);
for(i=0;i<5;i++)
{
line(x,y,x1[i],y1[i]);
line(x,y,x2[i],y2[i]);
line(x1[i],y1[i],x2[i],y2[i]);
line(x1[i],y1[i],x2[i+1],y2[i+1]);
}
for(i=0;i<10;i++)
{
setfillstyle(1,i%2?RED:LIGHTRED);
floodfill(x+10*cos((theta-90+i*36)*th),y-10*sin((theta-90+i*36)*th),RED);
}
}
void save()
{
FILE *fp;
if((fp=fopen("d:\\canshu_list","wb"))==NULL)
{printf("cannot open file\n");
exit(0);
}
if(fwrite(&canshu,sizeof(struct canshu),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}