📄 6.6.5.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='6.6.4b.htm'" ></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='6.6.5b.htm'"></img></td>
</tr>
</table>
<br><br>
<font class="title2"><b>练习</b></font>
<table><tr><td>    </td>
<td class="content">
<a name="6.1"></a>
6.1 利用Pascal的作用域规则,试确定下面Pascal程序中名字a和b的每一次出现所应用的说明。
<br>
<b><font color="#0000FF">program</font></b> a(input,output); <br>
<b><font color="#0000FF">procedure</font></b> b(u,v,x,y:
<b><font color="#0000FF"> integer</font></b>); <br>
<b> <font color="#0000FF">var</font></b> a:record a,b:
<font color="#0000FF"><b> integer</b></font>
<b><font color="#0000FF">end</font></b>; <br>
b: record b,a: <font color="#0000FF"><b>
integer</b></font> <b><font color="#0000FF">end</font></b>; <br>
<b> <font color="#0000FF">begin</font></b> <br>
<font color="#0000FF"><b>with</b></font> a
<font color="#0000FF"><b> do begin</b></font>
a:=u;b:=v <b><font color="#0000FF">end</font></b>; <br>
<font color="#0000FF"><b>with</b></font> b
<font color="#0000FF"><b> do begin</b></font>
a:=x; b:=y <b><font color="#0000FF">end</font></b>; <br>
writeln(a. a,a.
b,b.a,b.b) <br>
<b> <font color="#0000FF">end</font></b>; <br>
<b><font color="#0000FF">begin</font></b> <br>
b(1,2,3.4) <br>
<b><font color="#0000FF">end</font></b>.
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('key/a_6.1.htm','','left=100,top=100,toolbar=no,scrollbars=yes,width=600,height=500')"></img>
</td></tr>
</table>
<a name="6.2"></a>
<hr size=2 align=center color=red><br>
6.2 试问下面的程序将有怎样的输出?分别假定: <br>
(a)传值调用(call-by-value); <br>
(b) 引用调用(call-by-reference); <br>
(c)复制恢复(copy-restore); <br>
(d)传名调用(call-by-name)。 <br>
<b><font color="#0000FF">program</font></b> main(input,output); <br>
<b> <font color="#0000FF">procedure</font></b> p(x,y,z); <br>
<b> <font color="#0000FF">begin</font></b> <br>
y:=y+1;
<br>
z:=z+x;
<br>
<b> <font color="#0000FF">end</font></b>; <br>
<b> <font color="#0000FF">begin</font></b> <br>
a:=2; <br>
b:=3; <br>
p(a+b,a,a);
<br>
print a <br>
<b> <font color="#0000FF">end</font></b>.
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('key/a_6.2.htm','','left=100,top=100,toolbar=no,scrollbars=yes,width=600,height=450')" width="32" height="32">
</td></tr>
</table>
<hr size=2 align=center color=red><br>
<br>
<table align=right width=300>
<tr>
<td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='6.6.4b.htm'" ></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='6.6.5b.htm'"></img></td>
</tr>
</table>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -