📄 7.8.0c.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='7.8.0b.htm'" ></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'"
onclick="vbscript:window.location.href='../c_8/8.0.htm'" ></td>
</tr>
</table>
<p><br>
<br>
<font class="title2"><b>练习</b></font> </p>
<table>
<tr>
<td> </td>
<td class="content">
<p><a name="7.9"></a> </p>
<hr size="2" align="center" color="red">
7.9 Pascal语言中,语句 <br>
<table align="center" width="350">
<tr>
<td>for v:=initial to final do stmt</td>
<td> </td>
</tr>
</table>
<p><br>
与下列代码序列有相同含义</p>
<table align="center" width="350">
<tr>
<td>begin<br>
t<span class="down">1</span>:=initial;t<span class="down">2</span>:=final;<br>
if t<span class="down">1</span><=t<span class="down">2</span> then
begin<br>
v:=t<span class="down">1</span>;<br>
stmt<br>
while v<>t<span class="down">2</span> do begin<br>
v:=succ(v);<br>
stmt<br>
end<br>
end<br>
end </td>
</tr>
</table>
<p><br>
(a)试考虑下述Pascal程序<br>
</p>
<table align="center" width="350">
<tr>
<td>program forloop(input, output);<br>
var i,initial,final: integer;<br>
<strong> begin</strong><br>
read(initial, final);<br>
for i:= initial to final <strong>do<br>
</strong>write(i)<strong><br>
end</strong> </td>
</tr>
</table>
<p>对于initial=MAXINT-5和final= MAXINT,问此程序将做些什么?其中MAXINT为目标机器允许的最大整数。
<br>
*(b)试构造一个翻译pascal的for语句为三地址代码的语法制导定义。
<br>
</p>
<table align="center" width="70%">
<tr>
<td align="right"><img src="key.gif" onmouseover="javascript:style.cursor='hand'"
onclick="javascript:window.open('7.8.9.htm','','left=50,top=40,toolbar=no,scrollbars=yes,width=800,height=600')"
width="32" height="32"> </td>
</tr>
</table>
<hr size="2" align="center" color="red">
</p>
</td>
</tr>
</table>
<table align="right" width="300">
<tr>
<td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'"
onclick="vbscript:window.location.href='7.8.0b.htm'" ></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'"
onclick="vbscript:window.location.href='../c_8/8.0.htm'" ></td>
</tr>
</table>
</body>
</html>
<html><script language="JavaScript">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -