8.3 Комплексна вправа до роздiлiв 1-6
{ codeword = " bakbbkbckbbbambcbbmbcbambdtbetbbjbfu " + codeword; byte [] s = new byte [ 256 ]; byte top =( byte)( s. Length- 1); s [--top ] = 0; Proposition [] proof = new Proposition [ 256 ]; bool cheat _ mode = true; int pc = 0, goal =-1; for( i = 0; i < codeword. Length; i ++) { int code = codeword [ i ]-’ a’; if(! cheat _ mode) { if(( codeword [ i ] >=’ 0’ && codeword [ i ] <=’ 9’) ||( codeword [ i ] >=’ A’ && codeword [ i ] <=’ Z’)) code = codeword [ i ] ^ c1; else if((( code ^ c1) >=’ 0’ &&( code ^ c1) <=’ 9’) ||(( code ^ c1) >=’ A’ &&( code ^ c1) <=’ Z’)) break;
} int A, B; if( i == 0) cheat _ mode = true; switch( code) { case 0: i = codeword. Length; break; case 1: byte val =( byte)( codeword [++ i ]-’ a’); if(! cheat _ mode) { if(( codeword [ i ] >=’ 0’ && codeword [ i ] <=’ 9’) ||( codeword [ i ] >=’ A’ && codeword [ i ] <=’ Z’)) val =( byte)( codeword [ i ] ^ c1);
} s [--top ] = val; break; case 2: top ++; break; case 3: s [++ top ] += s [ top- 1 ]; break; case 4: s [++ top ]- = s [ top- 1 ]; break; case 5: s [++ top ] *= s [ top- 1 ]; break; case 6: s [++ top ] /= s [ top- 1 ]; break; case 7: s [--top ] = s [ top + 1 ]; break; case 8: if( goal < 0 || proof [ goal ]. IsAssertion) Console. Write(( char)( s [ top ++] +’ A’)); break; case 9: int target = s [ top ++], value = s [ top ++]; if( target > 127) target = target- 256; if( value!= 0) i += target; break; case 10: proof [ pc ]. IsAssertion = false; proof [ pc ]. Operation = s [ top ++]. ToString(); pc ++; break; case 11: proof [ pc ]. IsAssertion = false; proof [ pc ]. Operation = " NOT "; proof [ pc ]. Arg1 = s [ top ++];
177