HELP!CRASH in test 1!Please HELP ME!
Послано
GHLXLF 25 авг 2011 08:42
#include<stdio.h>
#include<string.h>
char s[100];
bool map[200][200],bo;
int n,m,x,y,xx,yy,a[11000],b[11000],c,zy;
void find(int xx,int yy,int xy)
{
bool l,r,s,x;
l=r=s=x=false;
map[xx][yy]=false;
if (map[xx+1][yy]) {printf("R");map[xx+1][yy]=false;c++;a[c]=xx+1;b[c]=yy;}
if (map[xx][yy+1]) {printf("T");map[xx][yy+1]=false;c++;a[c]=xx;b[c]=yy+1;}
if (map[xx-1][yy]) {printf("L");map[xx-1][yy]=false;c++;a[c]=xx-1;b[c]=yy;}
if (map[xx][yy-1]) {printf("B");map[xx][yy-1]=false;c++;a[c]=xx;b[c]=yy-1;}
if (xy==c) return;
printf(",\n");
if (xy<c)
find(a[xy+1],b[xy+1],xy+1);
}
int main()
{
memset(map,false,sizeof(map));
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
gets(s);
if (strlen(s)==1)
{
n=s[0]-48;
for (int i=1;i<=n;i++)
{
scanf("%d%d",&x,&y);
if (i==1)
{
xx=x;
yy=y;
}
map[x][y]=true;
}
a[1]=xx;
b[1]=xx;
c=1;
printf("%d %d\n",xx,yy);
find(xx,yy,1);
printf(".\n");
}
else
{
x=s[0]-48;
y=s[2]-48;
map[x][y]=true;
zy=1;
c=1;
while (true)
{
gets(s);
if (s[0]=='.') break;
for (int i=0;i<=strlen(s);i++)
{
if (s[i]=='R')
{ c++;a[c]=x+1;b[c]=y;
map[x+1][y]=true;
}
else
if (s[i]=='T')
{map[x][y+1]=true;c++;a[c]=x;b[c]=y+1;}
else
if (s[i]=='L')
{map[x-1][y]=true;c++;a[c]=x-1;b[c]=y;}
else
if (s[i]=='B')
{map[x][y-1]=true;c++;a[c]=x;b[c]=y-1;}
}
zy++;
x=a[zy];
y=b[zy];
}
printf("%d\n",zy);
for (int i=1;i<=10;i++)
for (int j=1;j<=10;j++)
if (map[i][j]) printf("%d %d\n",i,j);
}
}