請大神幫我看看這個(gè)程序。。。
第9題
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <stdbool.h>
int main()
{
?bool m[10][10]={false};
?bool n[10][10]={false};
?char a[10][10];
?char x[25]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
?int i,k,b,c,d=0,e=0,f=0,g,h,j,l;
?for(i=0;i<10;i++)
?{
??for(k=0;k<10;k++)
??{
???(a[i][k]='.');
??}
?}
?srand((unsigned) time(NULL));
?(a[e][f]='A');
?(m[e][f]=true);
?
?for(b=0;b<26;b++)
?{
??
??d++;
??(c=rand()%4);
?
??switch(c)
??{
???case 0:
???if(m[e][f-1])
???{n[e][f-1]=true;
???break;}
???(a[e][f-1]=x[d]);
???g=e;
???h=f-1;
???m[g][h]=true;
???break;
???
???case 1:
???if(m[e-1][f])
???{n[e-1][f]=true;
???break;}
???(a[e-1][f]=x[d]);
???g=e-1;
???h=f;
???m[g][h]=true;
???break;
???
???case 2:
???if(m[e][f+1])
???{n[e][f+1]=true;
???break;}
???(a[e][f+1]=x[d]);
???g=e;
???h=f+1;
???a[g][h]=true;
???break;
???
???case 3:
???if(m[e+1][f])
???{n[e+1][f]=true;
???break;}
???(a[e+1][f]=x[d]);
???g=e+1;
???h=f;
???m[g][h]=true;
???break;
???
??
???
??}
??
??e=g;
??f=h;
???
???if (g<0||h<0||g>9||h>9)
???break;
???if(n[g][h])
???break;
????}
???for(j=0;j<10;j++)
??{
???for(l=0;l<10;l++)
???printf("%c ",a[j][l]);
????printf("\n");
???
??
???
??}
?
?
?return 0;
}
2015-11-29
好長- -
2015-11-29
我是新手,?不太懂,?請指教。。。
2015-11-29
第九題??????哪兒錯(cuò)了????有時(shí)候會(huì)直接跳過幾個(gè)字母?還會(huì)輸出一個(gè)笑臉