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,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,}};
void randsnake()
{
int y = -1,
x = -1;
srand((unsigned)time(NULL));
x = rand() % 19 + 1;
y = rand() % 24 + 1;
snakeDraw =y;
snakeDraw =x;
snakeDraw =to_west;
snakeDraw =y;
snakeDraw =x + 1 ;
snakeDraw =to_west ;
snakeDraw =y;
snakeDraw =x + 2;
snakeDraw =to_west;
int i = 0;
for( i = 0; snakeDraw != 0; i++)
{
strncpy(&snakemap]], '*' ,1);
}
}
void snakemaap()
{
int i,j ;
for( i = 0 ;i < 21; ++i)
{
for( j = 0; j < 28; ++j)
{
if(snakemap==1)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
}
int main()
{
while(1)
{
system("cls");
snakemaap();
_sleep(1000);
}
randsnake();
system("pause");
return 0;
}
是这个代码出问题了吗?为啥在snakemap数组里面没有。
void randsnake()
{
int y = -1,
x = -1;
srand((unsigned)time(NULL));
x = rand() % 19 + 1;
y = rand() % 24 + 1;
snakeDraw =y;
snakeDraw =x;
snakeDraw =to_west;
snakeDraw =y;
snakeDraw =x + 1 ;
snakeDraw =to_west ;
snakeDraw =y;
snakeDraw =x + 2;
snakeDraw =to_west;
int i = 0;
for( i = 0; snakeDraw != 0; i++)
{
strncpy(&snakemap]], '*' ,1);
}
} 所以你要干什么??{:10_272:}SNAKEMAP是多少(请贴出全部代码并说明问题和目的。) int main()
{
while(1)
{
system("cls");
snakemaap();
_sleep(1000);
}
randsnake();
system("pause");
return 0;
}
一直循环在清屏和画图,后面的貌似都执行不了
页:
[1]