⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 right2-7.htm

📁 Visual C++面向对象程序设计教程(配套习题资源)
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>第 2 章</title>
<base target="rbottom">
<style>
<!--
.右标题   { font-size: 10pt; color: #000080; text-indent: 0; margin: 0 }
.右内容   { font-size: 10pt; text-align: left; text-indent: 0; line-height: 100%; margin: 
               0 }
-->
</style>
</head>

<body>

<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><span style="position: absolute; left: 4; top: -8"><img border="0" src="1.gif" width="63" height="70"></span></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p style="line-height: 100%; text-indent: 0; margin: 0" class="右标题" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        
&nbsp;&nbsp;&nbsp; <span style="background-color: #CCFF99">第 2 章</span><span style="background-color: #CCFF99">&nbsp;                       
</span>&gt;<span style="background-color: #CCFF99"> 第 7 节 </span>&gt;<span style="background-color: #CCFF99">    
 2.7 习题</span></p>          
<hr color="#008000" size="1">

<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">1.   
<font LANG="ZH-CN">编写程序将</font>d<font LANG="ZH-CN">天</font>h<font LANG="ZH-CN">小时</font>m<font LANG="ZH-CN">分钟换算成分钟,然后进行输出。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">2.   
<font LANG="ZH-CN">编写程序,输入两个整数,求出它们的商数和余数并进行输出。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">3.   
<font LANG="ZH-CN">编写程序,读入三个双精度数,求它们的平均值并保留此平均值小数点后一位,对小数点后第二位进行四舍五入,并输出结果。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">4.   
<font LANG="ZH-CN">编写程序,读入三个整数</font>a<font LANG="ZH-CN">、</font>b<font LANG="ZH-CN">、</font>c<font LANG="ZH-CN">,然后交换它们中的数,把</font>a<font LANG="ZH-CN">中原来的值给</font>b<font LANG="ZH-CN">,把</font>b<font LANG="ZH-CN">中的值给</font>c<font LANG="ZH-CN">,把</font>c<font LANG="ZH-CN">中的值给</font>a<font LANG="ZH-CN">。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">5.   
<font LANG="ZH-CN">给出一个不多于</font>5<font LANG="ZH-CN">位的正整数,要求求出它是几位数,分别打印出每一位数字,按逆序打印出各位数字。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">6.   
<font LANG="ZH-CN">编写程序,输入一位学生的生日,并输入当前的日期,输出该生的实足年龄。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">7.   
<font LANG="ZH-CN">编写程序,输入一个整数,打印它是奇数还是偶数。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">8.   
<font LANG="ZH-CN">某企业利润提成的规则如下:</font></font></p>
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">①</font> 
<font LANG="ZH-CN">利润低于或等于</font>10<font LANG="ZH-CN">万元的,奖金可提取</font>10%<font LANG="ZH-CN">。</font></font></p>  
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">②</font> 
<font LANG="ZH-CN">利润高于</font>10<font LANG="ZH-CN">万元,低于</font>20<font LANG="ZH-CN">万元时,低于</font>10<font LANG="ZH-CN">万元的按</font>10%<font LANG="ZH-CN">提成,高于部分按</font>7.5%<font LANG="ZH-CN">提成。</font></font></p>  
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">③</font> 
<font LANG="ZH-CN">利润高于</font>20<font LANG="ZH-CN">万元低于</font>40<font LANG="ZH-CN">万元的,其中</font>20<font LANG="ZH-CN">万元按前面的方法发放,高于部分按</font>5%<font LANG="ZH-CN">提成。</font></font></p>  
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">④</font> 
<font LANG="ZH-CN">利润高于</font>40<font LANG="ZH-CN">万元的,</font>40<font LANG="ZH-CN">万元按前面的方法提成,高于部分按</font>3%<font LANG="ZH-CN">提成。</font></font></p>  
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font LANG="ZH-CN" size="2">从键盘输入利润,求应发的提成。</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">9.   
<font LANG="ZH-CN">打印出所有的“水仙花”数,所谓“水仙花”是指一个</font>3<font LANG="ZH-CN">位数,其各位数字立方和等于该数本身。例如</font>153<font LANG="ZH-CN">是个水仙花数,因为</font>153=1<sup>3</sup> 
+5<sup>3</sup> +3<sup>3</sup> <font LANG="ZH-CN">。</font></font></p>  
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">10.   
<font LANG="ZH-CN">编写程序找到</font>1000<font LANG="ZH-CN">以内的所有“完数”。所谓“完数”是指一个数为其所有因子之和。例如</font>6=1+2+3<font LANG="ZH-CN">。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">11.   
<font LANG="ZH-CN">用迭代法求</font><img SRC="Image1.gif" WIDTH="59" HEIGHT="30"><font LANG="ZH-CN">。求平方根的迭代公式为</font><img SRC="Image2.gif" WIDTH="135" HEIGHT="51"><font LANG="ZH-CN">。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">12.   
<font LANG="ZH-CN">编写程序输出从公元</font>1000<font LANG="ZH-CN">年至</font>2000<font LANG="ZH-CN">年所有闰年的年号,每输出</font>3<font LANG="ZH-CN">个年号换一行。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">13.   
<font LANG="ZH-CN">输入一行字符,统计其中有多少个单词(单词间以空格分隔)。比如,输入“</font>I   
am a boy.<font LANG="ZH-CN">”,有</font>4<font LANG="ZH-CN">个单词。</font></font></p>  
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">14.   
<font LANG="ZH-CN">定义字符指针数组,包含</font>5<font LANG="ZH-CN">个数组元素。同时再定义一个二维字符数组,其数组大小为</font>5<font LANG="ZH-CN">×</font>10<font LANG="ZH-CN">,即</font>5<font LANG="ZH-CN">行</font>10<font LANG="ZH-CN">列,可存放</font>5<font LANG="ZH-CN">个字符串。若将各字符串的首地址传递给指针数组各元素,那么指针数组就成为名副其实的字符串数组。编写程序要求对各字符串按字典排序。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">15.   
<font LANG="ZH-CN">编写程序,调用传递引用的参数,实现两个字符串的交换。例如开始:</font></font></p>
<blockquote>
  <blockquote>
    <p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">char   
    *pa=&quot;hello&quot;;</font></p>
    <p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">char 
    *pb=&quot;how are you&quot;;</font></p>
  </blockquote>
</blockquote>
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">交换的结果使得</font>pa<font LANG="ZH-CN">和</font>pb<font LANG="ZH-CN">指向的内容互换。</font></font></p>

<p style="line-height: 100%; text-indent: 0; margin: 0" class="右标题" align="left"> </p>

<hr size="1" color="#008000">
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0">&nbsp;&nbsp; <span style="position: absolute; left: 30; top: 617"><a href="right2-6.htm" target="_self"><img border="0" src="rightd1.gif" width="113" height="70"></a></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="position: absolute; left: 498; top: 622"><a href="right3-1.htm" target="_self"><img border="0" src="rightd2.gif" width="124" height="63"></a></span></p>    

</body>

</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -