//Programed By FR, Su 15/08/2006
//program robcom { campo minado I }
#include<mem.h>
#include<PROCESS.H>
#include<fstream.H>
void readdata();
void check();
short int m,n,i,j,k,
ox,oy,dx,dy,
c[102][102];
char o,ch,ori,oper[41];
void main()
{
memset(c,1,sizeof(c));
readdata();
check();
};//main
void readdata()
{
ifstream fe("robcom.dat");
fe>>m>>ch>>n;
for (i = 1; i <= m; i++) {
for (j = 1; j < n; j++)
fe>>c[i][j]>>ch;
fe>>c[i][n];
};
fe>>ox>>ch>>oy;
fe>>dx>>ch>>dy;
fe>>ori;
fe>>k;
i = 0;
for ( ; i < k; ++i)
fe>>oper[i];
fe.close();
};//readdata
void no()
{
ofstream fs("robcom.res");
o = 'E';
fs<<o;
fs.close();
exit(1);
};
void check()
{
for (i = 0; i < k; i++)
{
switch (oper[i])
{
case 'D' :
{
switch(ori)
{
case 'N' : { ori = 'E'; break; }
case 'S' : { ori = 'O'; break; }
case 'E' : { ori = 'S'; break; }
case 'O' : { ori = 'N'; break; }
};
break;
}; //D
case 'I' :
{
switch(ori)
{
case 'N' : { ori = 'O'; break; }
case 'S' : { ori = 'E'; break; }
case 'E' : { ori = 'N'; break; }
case 'O' : { ori = 'S'; break; }
};
break;
}; //I
default :
{
switch(ori)
{
case 'N' :
{
if (c[ox-1][oy] != 0) no();
ox--;
break;
}
case 'S' :
{
if (c[ox+1][oy] != 0) no();
ox++;
break;
}
case 'E' :
{
if (c[ox][oy+1] != 0) no();
oy++;
break;
}
case 'O' :
{
if (c[ox][oy-1] != 0) no();
oy--;
break;
}
};
}; // A, default
};//switch
};//for i
if ((ox = dx) & (oy = dy))
{
ofstream fs("robcom.res");
o = 'C';
fs<<o;
fs.close();
}
else no();
}; //check
|