[color=#000000]考虑具有下列规则的文法[/color][color=#000000][color=#000000]S→E# E→T|E+T T→P| P↑T P→F|P*F F→i|(E)[/color][/color][color=#000000][color=#000000]下列句型的最右推导步骤中,其活前缀的集合是什么?[/color][/color][color=#000000][color=#000000](1) E+i*i# [/color][/color][color=#000000][color=#000000](2) E+P↑(i+i)# [/color][/color]
举一反三
- 对下面的文法 G[E]:[color=#000000]E [/color][color=#000000]→ [/color][color=#000000]TE‘[/color][color=#000000]E' → + E |ε [/color][color=#000000]T → FT' [/color][color=#000000]T' → T |ε [/color][color=#000000]F → PF' [/color][color=#000000]F' → * F' |ε [/color][color=#000000]P →(E)| a | b | ∧[/color][color=#000000]证明这个文法是 [/color][color=#000000]LL(1)[/color][color=#000000]的.[/color]
- 对下面的文法 G[E]:[color=#000000]E [/color][color=#000000]→ [/color][color=#000000]TE‘[/color][color=#000000]E' → + E |ε [/color][color=#000000]T → FT' [/color][color=#000000]T' → T |ε [/color][color=#000000]F → PF' [/color][color=#000000]F' → * F' |ε [/color][color=#000000]P →(E)| a | b | ∧[/color][color=#000000]构造它的预测分析表.[/color]
- [color=#000000]试编写递归算法,逆转广义表中的数据元素。[/color][color=#000000][color=#000000]例如,将广义表([/color][color=#000000][i]a[/i][/color][color=#000000],(([/color][color=#000000][i]b[/i][/color][color=#000000],[/color][color=#000000][i]c[/i][/color][color=#000000]),( )),((([/color][color=#000000][i]d[/i][/color][color=#000000]),[/color][color=#000000][i]e[/i][/color][color=#000000]),[/color][color=#000000][i]f[/i][/color][color=#000000])) [/color][/color][color=#000000][color=#000000]逆转为(([/color][color=#000000][i]f[/i][/color][color=#000000],([/color][color=#000000][i]e[/i][/color][color=#000000],([/color][color=#000000][i]d[/i][/color][color=#000000]))),(( ),([/color][color=#000000][i]c[/i][/color][color=#000000],[/color][color=#000000][i]b[/i][/color][color=#000000])),[/color][color=#000000][i]a[/i][/color][color=#000000])。[/color][/color]
- [color=#000000]请画出下列广义表的图形表示。 [/color][color=#000000](1)[/color][color=#000000][i]D[/i][/color][color=#000000]([/color][color=#000000][i]A[/i][/color][color=#000000](),[/color][color=#000000][i]B[/i][/color][color=#000000]([/color][color=#000000][i]e[/i][/color][color=#000000]),[/color][color=#000000][i]C[/i][/color][color=#000000]([/color][color=#000000][i]a[/i][/color][color=#000000],[/color][color=#000000][i]L[/i][/color][color=#000000]([/color][color=#000000][i]b[/i][/color][color=#000000],[/color][color=#000000][i]c[/i][/color][color=#000000],[/color][color=#000000][i]d[/i][/color][color=#000000])))。 [/color][color=#000000](2)[/color][color=#000000][/color][tex=16.5x1.357]2//TDXVdRsUjJeqqAHc4/O/T0Y9dJEUv7hSuEhI4XIwjwRCCxPU0z0++4d4GPBJl74OoLLIjvae3/PwpxOpAcKqMHPXRYBE1MtHSEDFRITb/ZQOJgeP9m5Zy7zmikHt2hsbWGiGY3AYukBRVCbNPbmSluqwE+SOnxqLbpw6cQcg=[/tex][color=#000000]。[/color]
- 写出下列程序的执行结果[color=#000000]#include <stdio.h> [/color][color=#000000]int main(void) [/color][color=#000000]{ [/color][color=#000000] int a[10], b[10], *pa, *pb, i; [/color][color=#000000] pa = a; [/color][color=#000000] pb = b; [/color][color=#000000] for( i=0; i<3; i++, pa++, pb++) [/color][color=#000000] { [/color][color=#000000] *pa = i; [/color][color=#000000] *pb = 2*i; [/color][color=#000000] printf(“%d\t%d\n”, *pa, *pb); [/color][color=#000000] } [/color][color=#000000] pa = &a[0]; [/color][color=#000000] pb = &b[0]; [/color][color=#000000] for ( i=0; i<3; i++) [/color][color=#000000] { [/color][color=#000000] *pa = *pa + i; [/color][color=#000000] *pb = *pb + i; [/color][color=#000000] printf(“%d\t%d\n”, *pa++, *pb++); [/color][color=#000000] } [/color][color=#000000][color=#000000] return 0; [/color][/color][color=#000000]} [/color]