{
Class Program
{
Class GS
{
public char old, input, newch;
}
static void Main(string[] args)
{
GS[] sost = new GS[16];
for(short q=0;q<=15;++q){
sost[q] = new GS();
}
string str,sm; char neterm; bool flag;
sost[0].old = 'S'; sost[0].input = '1'; sost[0].newch = 'A';
sost[1].old = 'A'; sost[1].input = '1'; sost[1].newch = 'B';
sost[2].old = 'A'; sost[2].input = '0'; sost[2].newch = 'W';
sost[3].old = 'B'; sost[3].input = '0'; sost[3].newch = 'C';
sost[4].old = 'C'; sost[4].input = '0'; sost[4].newch = 'S';
sost[5].old = 'D'; sost[5].input = '1'; sost[5].newch = 'E';
sost[6].old = 'E'; sost[6].input = '0'; sost[6].newch = 'F';
sost[7].old = 'F'; sost[7].input = '1'; sost[7].newch = 'T';
sost[8].old = 'F'; sost[8].input = '0'; sost[8].newch = 'K';
sost[9].old = 'K'; sost[9].input = '0'; sost[9].newch = 'D';
sost[10].old = 'R'; sost[10].input= '1'; sost[10].newch = 'M';
sost[11].old = 'M'; sost[11].input= '0'; sost[11].newch = 'N';
sost[12].old = 'N'; sost[12].input= '1'; sost[12].newch = 'T';
sost[13].old = 'T'; sost[13].input= '1'; sost[13].newch = 'R';
sost[14].old = 'W'; sost[14].input= '1'; sost[14].newch = 'T';
sost[15].old = 'W'; sost[15].input= '0'; sost[15].newch = 'K';
While (true)
{
Console.WriteLine(" Введите строку ");
str = Console.ReadLine();
short n = 0; flag = true;
if (str.Length < 0)
{
Console.WriteLine(" Пустая Строка ");
flag = false;
};
neterm = 'S';
short i;
while (n < str.Length)
{
i = 0;
++n;
sm = str.Substring(n-1, 1);
flag = false;
Console.WriteLine(neterm);
do
{
if ((sost[i].old == neterm) & (sost[i].input.ToString() == sm))
{
flag = true;
neterm = sost[i].newch;
break;
}
++i;
}
while (i < 16);
};
if ((flag == true) & (str.Length != 0))
{
Console.WriteLine(neterm);
}
Else
{
Console.WriteLine('0');
};
if (((neterm == 'S') | (neterm == 'D') | (neterm == 'R')) && flag)
{
Console.WriteLine("TRUE");
}
else{
Console.WriteLine("False");
};
}
}
} }.