📄 9.13c.htm
字号:
<html>
<head>
<title>编译原理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link type="text/css" rel="stylesheet" href="../css/specification.css">
</head>
<BODY>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.13b.htm'"></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.13d.htm'"></img></td>
</tr>
</table>
<br><br>
<font class="title2"><b>练习</b></font>
<table><tr><td>    </td>
<td class="content">
9.5 下面是应用筛法求2到N之间素数的程序:<br>
<font color="#0000FF">begin</font><br>
<font color="#0000FF">read</font> N;<br>
<font color="#0000FF">for</font> i := 2 <font color="#0000FF">to</font> N
<font color="#0000FF">do</font><br>
A[i] := <font color="#0000FF">true</font>;
<font color="#008000">/*置初值*/</font><br>
<font color="#0000FF">for</font> i := 2 <font color="#0000FF">to</font> N**0.5
<font color="#0000FF">do</font>
<font color="#008000">/*运算符**代表幂乘*/</font><br>
<font color="#0000FF">if</font> A[i] <font color="#0000FF">then</font>
<font color="#008000">/*i是一个素数*/</font><br>
<font color="#0000FF">for</font> j := 2 * i to<b> </b>N <font color="#0000FF">by</font> i
<font color="#0000FF">do</font><br>
A[j] := <font color="#0000FF">false</font>
<font color="#008000">/*j可被i除尽*/</font><br>
<font color="#0000FF">end</font><br>
(1)试写出其四元式中间代码,假设对数组A用静态分配存储单元,且下届为0;<br>
(2)作出流图并求出其中的循环;<br>
(3)进行代码外提;<br>
(4)进行强度削弱和删除归纳变量;<br>
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('9.13.5.htm','','left=100,top=100,toolbar=no, scrollbars = yes, width=600,height=600')" width="32" height="32"></img>
</td></tr>
</table>
<a name="9.6"></a>
<hr size=2 align=center color=red><br>
9.6 对下面的程序片段作出其程序流图并计算:<br>
(1)各基本块的到达_定值集IN[B];<br>
(2)各基本块中各变量引用点的ud链;<br>
(3)各基本块出口的活跃变量集V_OUT[B];<br>
(4)各基本块中变量定值点的du链。<br><br>
I := 1<br>
J := 0<br>
L1: J := J + I<br>
<font color="#0000FF">read</font> I<br>
<font color="#0000FF">if</font><b> </b>I < 100 <font color="#0000FF">goto</font> L2<br>
<font color="#0000FF">write</font> J<br>
<font color="#0000FF">halt</font><br>
L2 : I := I * I<br>
<br>
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('9.13.6.htm','','left=100,top=100,toolbar=no, scrollbars = yes, width=750,height=500')" width="32" height="32"></img>
</td></tr>
</table>
<hr size=2 align=center color=red><br>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.13b.htm'"></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.13d.htm'"></img></td>
</tr>
</table>
</BODY>
</html>
<html><script language="JavaScript">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -