📄 c02_41.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>练习题一 </title>
<script language="javascript">
function init(){
exp=expdiv.style;
}
function show(obj){
obj.display='';
}
function hide(obj){
obj.display='none';
}
</script>
</head>
<body bgcolor="#ccefcc" onLoad="init()">
<blockquote>
<p>请修改这个程序。</p>
<div align="center"><center><table border="6" width="470" cellspacing="0" cellpadding="6"
height="150" bordercolor="#FF9933">
<tr>
<th width="694" bgcolor="#FF9933">有错的程序</th>
</tr>
<tr>
<td ALIGN="center" width="694" bgcolor="#00FFFF"><p align="left">include studio.h<br>
main{}<br>
/* this program prints the number of weeks in a year. /*<br>
(<br>
int s<br>
s:=52;<br>
print(There are s weeks in a year");</td>
</tr>
</table>
</center></div><p><br>
仔细想一想程序有哪些错误, <a href="javascript:show(exp)">这里</a>得到错误的原因及正确的程序。</p>
<div id="expdiv" style="display:'none'"><p>在第一行中有三个错误。<ol>
<li>以 <font color="#FF0000">#</font> 开始一行。</li>
<li>studio.h 应为 <font color="#FF0000">stdio.h</font></li>
<li>把文件名放在 <font color="#FF0000">< ></font> 中。</li>
</ol>
<p><br>
在第二行中有一个错误。是 <font color="#FF0000">()</font>, 不是 {}。</p>
<p>在第三行中有一个错误。注释是以 <font color="#FF0000">*/</font> 结束,
而不能用 /* 结束。</p>
<p>在第四行中有一个错误。函数体以 <font color="#FF0000">{</font> 开始。</p>
<p>在第五行中有一个错误。语句结尾使用 <strong><font color="#FF0000">;</font></strong></p>
<p>在第六行中有一个错误。赋值语句中用 <font color="#FF0000">=</font>,
而不用 :=</p>
<p>在第七行中有三个错误。<ol>
<li>是 <font color="#FF0000">printf</font> 而不是 print</li>
<li>缺少 <font color="#FF0000">"</font></li>
<li>打印十进制整数要用 <font color="#FF0000">%d</font> </li>
</ol>
<p>在第八行中有一个错误。函数体以 <font color="#FF0000">}</font> 结束。<br>
</p>
<div align="center"><center><table border="6" width="470" cellspacing="0" cellpadding="6"
height="150" bordercolor="#FF9933">
<tr>
<th width="694" bgcolor="#FF9933">正确的程序</th>
</tr>
<tr>
<td ALIGN="center" width="694" bgcolor="#00FFFF"><p align="left">#include <stdio.h><br>
main()<br>
/* this program prints the number of weeks in a year. */<br>
{<br>
int s;<br>
s=52;<br>
printf("There are %d weeks in a year",s);<br>
}</td>
</tr>
</table>
</center></div></div>
</blockquote>
<p align="center"><a href="javascript:close()">关闭</a></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -