, , , .
: ; , ; , , ( ) ..
, P; N -. -
struct lex {int class; int value;},
class:
0 - - ( )
1 - true false ( - )
2 - ( - )
3 -
4 - - ( - )
5 - - ( - ).
, , address TID TNUM, .
- , .
void interpreter(void) {
int *ip;
int i, j, arg;
for (i = 0; i<=N; i++)
{curr_lex = P[i];
switch (curr_lex.class) {
case 0: ipush (curr_lex.value); break;
/* - */
case 1: if (eq ("true")) ipush (1);
else ipush (0); break;
/* - */
case 2: if (eq ("+")) {ipush (ipop() + ipop()); break};
/* , - */
if (eq ("-"))
{arg = ipop(); ipush (ipop() - arg); break;}
/*
*/
if (eq ("not")) {ipush (!ipop()); break;};
if (eq ("!")) {j = ipop(); i = j-1; break;};
/* j-
*/
if (eq ("!F")) {j = ipop(); arg = ipop();
if (!arg) {i = j-1}; break;};
/* arg ,
j - ,
*/
if (eq (":=")) {arg = ipop(); ip = (int*)ipop();
*ip = arg; break;};
if (eq ("R")) {ip = (*int) ipop();
scanf("%d", ip); break;};
/* "R" - */
if (eq ("W")) {arg = ipop();
printf ("%d", arg); break;};
/* "W" - */
case 3: ip = TNUM [curr_lex.value].address;
ipush(*ip); break;
/* - */
case 4: ip = TID [curr_lex.value].address;
ipush(*ip); break;
/* - */
case 5: ip = TID [curr_lex.value}.address;
ipush((int)ip); break;
/* - */
} /* switch */
} /* for */
|
|
}
.
63. :
) a+b-c
b) a*b+c/a
c) a/(b+c)*a d) (a+b)/(c+a*b)
e) a and b or c f) not a or b and a
g) x+y=x/y h ) (x*x+y*y < 1) and (x > 0)
64.
:
) ab*c+ b) abc*/ c) ab+c*
d) ab+bc-/a+ e) a not b and not f) abca and or and
g ) 2x+2x*<
65. , :
) x y*x y /+ x = 8, y = 2;
b) a 2+b / b 4*+ a = 4, b = 3;
c) a b not and a or not a = b = true;
d) x y*0 > y 2 x - < and x = y = 1.
66. , , :
) if (x!= y) x = x+1; x = 3;
b) if (x > y) x = y; else y = x; x = 5, y = 7;
c) while (b > a) b = b-a;; a = 3, b = 7;
*d) do {x = y; y = 2*y;} while (x < k); y = 2; k = 15;
e) S = 0; for (i = 1; i <= k; i = i + 1) S = S + i*i; k = 3;
f) switch (k) {
case 1: a = not a; break;
case 2: b = a or not b;
case 3: a = b;
}
k = 2, a = b = false.
*67. , , , x = 9, y = 15 (, 1).
z, x, y, *,:=, x, y, <>, 30,!F, x, y, <, 23,!F, y, y, x, -,:=, 28,!, x, x, y, -,:=, 6,!, z, z, x, /,:=
, goto.
68. . ( ).
a) for I:= E1 to E2 do S ( )
b) case E of ( )
c1: S1; c2: S2;... cn: Sn
end
c) repeat S1; S2;...;Sn until B ( )
*d) goto.
P program D; S { S } end
D ...
S L: S | S
S ... | goto L |...
L -
*e) if (E) S1; S2; S3
: ; 0, S1 ; 0 - S2, - S3
*f) choice (S1; S2; S3), E
: ; i, Si i = 1, 2, 3; choice .
*g) cycle (E1; E2; E3), S
for , S , , (.. 1 S, 3, - 2, , for).
69. :
a) case k of
1: begin a:=not(a or b and c); b:=a and c or b end;
2: begin a:=a and (b or not c); b:= not a end;
3: begin a:=b or c or not a; b:==b and c or a end
end
b) S:=0; for i:=1 to N do
begin d:=i*2; a:=a+d*((i-1)*N+5)
S:=-a*d+S
end
c) c:=a*b; while a<>b do
if a < b then b:=b-a else a:=a-b;
c:=c/a
70. , , +, -, *, / (), , . .
|
|
71. - ( ). , . , , .
72. -, ,
E T {+T}
T F {*F}
F (E) | i
, , (, a*-b+-c a*(-b)+(-c).
. C.
73. , :
E TE E +TE | e
T FT T *FT | e
F PF F ^PF | e
P (E) | i
. .
74. , , +, -, *, /, ** () . ( ). .
75. , , ( ) .
,
+b ==> + (a, b)
a+b*c ==> + (a, * (b, c))
*76. L1, L1 L2.
L1 = { 1m 0n | n,m>0}
L2 = { 1m-n | m>n;
0n-m | m<n;
e | m=n}
( ).
77. L1, L1 L2.
L1 = {1n 0m 1m 0n | m,n > 0}
L2 = {1m 0n+m | m,n > 0}
78. L1, L1 L2.
L1 = {bi | bi =(i)2, .. bi - i Î N}
L2 = {(bi+1)R | bi+1=(i+1)2, wR - w}
79. , ( ). .
*80. L1. L1 L2.
L1={ w^ | w Î {a,b}+, w=an, a=ab | ba, n>=1}
L2={ w^ | w = bn, b={ b, a=ab; a, a=ba} }
*81. L1. L1 L2.
L1={ a^ | a Î {a,b}* }
L2={ b^ | b = bnaR, n - b a, a; aR - a}
*82. L1. L1 L2.
L1={ w^ | w Î {a,b}+, n a m b, }
L2={ w Î {a,b} * | w = a[n/2] b[m/2] }
*83. L1. L1 L2.
L1={w^ | wÎ{0,1}+, (bi)R, .. i }
L2={w Î {/} *, w = /i, .. /, i }
1. .. . - ., , 1975.
|
|
2. ., ., .. . - ., , 1979.
3. ., .. , . - . 1,2. - ., , 1979.
4. .. . - ., , 1977.
5. ... . - ., , 1975.
6. .. - . - ., , 1970.
7. .. . - ., , 1975.
8. ... . - ., , 1975.
9. ... - . - ., , 1995.
......
........................................................................................................................
...........................................................................
...........................................
...................................................................................
..............................................................................................................
....................................................................................
...........................................................................................................................
.............................................................
......................................................................................................................
........................................................................................
..................................................................................................
...............................................................................
.......................................................................................
-.......................................................................
............................................................................................................................ 30
..........................................................
........................................................................................
.........................................................
-................................................................
...........................................................................................
-.................................................................
............................................................................................................................
............................................
..........................................................
........................................................................
-.............................................
....................................................
|
|
............................................................................................................................
............................................................................................................ 61
.......................................................................................................... 62