| 
 | 
back to boardwhy the result is"Access Violation"!!!!!!!!!!!!!!! #include<iostream> using namespace std; int main() {     char a,b,c[10];     int N,K=0;     int line[400];     int open=0,close=0;     int tx,ty,i=0,j=0;     bool mat[20][20]={false};     int  rec[20][20];     //////////////////////////////////////////////////////////// //////////////////////////////////////     for(i=0;i<10;i++)     {         for(j=0;j<10;j++)             rec[i][j]=-1;
      }     cin>>a>>b>>c;     if(c[0]>='1'&&c[0]<='9')goto dep1;     else goto dep2; dep1:     K=0;     N=(int)a-48;     tx=(int)b-48;ty=(int)c[0]-48;     mat[tx][ty]=true;     rec[tx][ty]=0;       for(i=1;i<N;i++)     {         cin>>tx>>ty;         mat[tx][ty]=true;     }
 
      tx=(int)b-48;ty=(int)c[0]-48;     cout<<tx<<" "<<ty<<endl;     while(1)     {        if(mat[tx+1][ty]==true&&rec[tx+1][ty]==-1)        {         cout<<"R";         line[close++]=tx+1;         line[close++]=ty;         rec[tx+1][ty]=0;         }         if(mat[tx][ty+1]==true&&rec[tx][ty+1]==-1)        {           cout<<"T";           line[close++]=tx;           line[close++]=ty+1;           rec[tx][ty+1]=0;         }         if(mat[tx-1][ty]==true&&rec[tx-1][ty]==-1)         {             cout<<"L";             line[close++]=tx-1;             line[close++]=ty;             rec[tx-1][ty]=0;         }         if(mat[tx][ty-1]==true&&rec[tx][ty-1]==-1)         {             cout<<"B";             line[close++]=tx;             line[close++]=ty-1;             rec[tx][ty-1]=0;         }         K++;         if(K==N)        {              cout<<"."<<endl;              break;        }        cout<<","<<endl;        tx=line[open++];        ty=line[open++];     }     goto end; dep2:     tx=(int)a-48;ty=(int)b-48;     mat[tx][ty]=true;     i=0;     while(1)     {         i=0;         if(c[i]=='R')         {             mat[tx+1][ty]=true;             i++;             line[close++]=tx+1;             line[close++]=ty;         }         if(c[i]=='T')         {             mat[tx][ty+1]=true;             i++;             line[close++]=tx;             line[close++]=ty+1;         }         if(c[i]=='L')         {             mat[tx-1][ty]=true;             line[close++]=tx-1;             line[close++]=ty;             i++;         }         if(c[i]=='B')         {             mat[tx][ty-1]=true;             i++;             line[close++]=tx;             line[close++]=ty-1;         }         if(c[i]==',')         {             cin>>c;             tx=line[open++];             ty=line[open++];         }
          if(c[i]=='.')         {             K++;             break;         }         else           K++;
      }     cout<<K<<endl;     for(i=0;i<20;i++)         for(j=0;j<20;j++)             if(mat[i][j]==true)                 cout<<i<<" "<<j<<endl;   end:     ;     }  |  
  | 
|