匿名用户
1级
2014-11-18 回答
//流星tc版
#include
#include
#include
voidPrint(intplace[25][80])//,intcolor[10],intstar[10])
{
inti,j;
for(i=0;i<25;i++)
for(j=0;j<80;j++)
if(place[i][j]!=0&&place[i][j]!=-1)
{
printf("%c",'A'+place[i][j]-1);
}
elseif(place[i][j]==-1)
printf("#");
else
printf("");
}
voidEnd(intplace[25][80])
{
inti,j;
for(i=19;i<25;i++)
for(j=0;j<80;j++)
if(place[i][j]==-1)
break;
if(i==25&&j==80)
exit(0);
}
voidmain()
{
intspeed[10],dir[10],x[10],y[10],star[10];
inti,j;
intplace[25][80]={0};
srand((int)time(0));
for(i=19;i<25;i++)
for(j=0;j<80;j++)
place[i][j]=-1;
for(i=0;i<10;i++)
{
x[i]=0;y[i]=rand()%80;
speed[i]=rand()%2+1;
dir[i]=rand()%5-2;
star[i]=rand()%26+1;
}
while(1)
{
for(i=0;i<10;i++)
place[x[i]][y[i]]=star[i];
Print(place);
for(i=0;i<10;i++)
place[x[i]][y[i]]=0;
sleep(1);//将画面停留0.1(100毫秒)秒
clrscr();
for(i=0;i<10;i++)
{
x[i]+=speed[i];
y[i]+=dir[i];
if(y[i]>=80||y[i]<0||x[i]>=25||place[x[i]][y[i]]==-1)
{
if(place[x[i]][y[i]]==-1&&y[i]>0&&y[i]<=80&&x[i]<25)
place[x[i]][y[i]]=0;
x[i]=0;y[i]=rand()%80;
speed[i]=rand()%2+1;
dir[i]=rand()%5-2;
star[i]=rand()%26+1;
}
}
End(place);
//for(i=0;i<10;i++)
//place[x[i]][y[i]]=1;
}
}