c语言流星雨代码实现(手机c语言流星雨特效)
c语言程序设计流星雨的实现该如何写
//流星tc版
#includestdio.h
#includestdlib.h
#includetime.h
void Print(int place[25][80])//,int color[10],int star[10])
{
int i,j;
for(i=0;i25;i++)
for(j=0;j80;j++)
if(place[i][j]!=0place[i][j]!=-1)
{
printf("%c",'A'+place[i][j]-1);
}
else if(place[i][j]==-1)
printf("#");
else
printf(" ");
}
void End(int place[25][80])
{
int i,j;
for(i=19;i25;i++)
for(j=0;j80;j++)
if(place[i][j]==-1)
break;
if(i==25j==80)
exit(0);
}
void main()
{
int speed[10],dir[10],x[10],y[10],star[10];
int i,j;
int place[25][80]=;
srand((int)time(0));
for(i=19;i25;i++)
for(j=0;j80;j++)
place[i][j] = -1;
for(i=0;i10;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;i10;i++)
place[x[i]][y[i]] = star[i];
Print(place);
for(i=0;i10;i++)
place[x[i]][y[i]] = 0;
sleep(1);//将画面停留0.1(100毫秒)秒
clrscr();
for(i=0;i10;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]]==-1y[i]0y[i]=80x[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;i10;i++)
// place[x[i]][y[i]] = 1;
}
}
c语言流星雨代码编译不会报错
c语言流星雨代码编译不会报错。不会报错的前提是代码格式得正确,只能使用c语言的相关语句不能使用java。
c语言流星雨
#includestdio.h
#includestdlib.h
#include windows.h
void Print(int place[25][80])//,int color[10],int star[10])
{
int i,j;
for(i=0;i25;i++)
for(j=0;j80;j++)
if(place[i][j]!=0place[i][j]!=-1)
{
printf("%c",'A'+place[i][j]-1);
}
else if(place[i][j]==-1)
printf("#");
else
printf(" ");
}
void End(int place[25][80])
{
int i,j;
for(i=19;i25;i++)
for(j=0;j80;j++)
if(place[i][j]==-1)
break;
if(i==25j==80)
exit(0);
}
void main()
{
int speed[10],dir[10],x[10],y[10],star[10];
int i,j;
int place[25][80]={0};
srand((int)time(0));
for(i=19;i25;i++)
for(j=0;j80;j++)
place[i][j] = -1;
for(i=0;i10;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;i10;i++)
place[x[i]][y[i]] = star[i];
Print(place);
for(i=0;i10;i++)
place[x[i]][y[i]] = 0;
Sleep(100);
system("clrscr");
for(i=0;i10;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]]==-1y[i]0y[i]=80x[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;i10;i++)
// place[x[i]][y[i]] = 1;
}
}