第一范文网 - 专业文章范例文档资料分享平台

c++-primer-plus(第六版)第二至第六章课后编程练习全部答案

来源:用户分享 时间:2025/7/31 2:32:19 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

double sum=0,average=0;

arrayad={0}; int i=0,total=0;

double temp;

while(cin>>temp&&i<10&&!isdigit(temp)) {

ad[i]=temp; sum+=ad[i]; ++i; }

if(i!=0) average=sum/i;

for(int j=0;javerage) ++total;

cout<<\这些数字的平均值为\ cout<<\并且共有\个数字大于平均值。\\n\

return 0; }

//ex.6.3

#include

int main() {

using namespace std;

cout<<\ <<\

<<\书上的这个f个人认为是打印错误

cout<<\

char ch; cin>>ch;

while(ch!='c'&&ch!='p'&&ch!='t'&&ch!='g')

{

cout<<\ cin>>ch; }

switch(ch) {

case 'c':

cout<<\ break; case 'p':

cout<<\ break; case 't':

cout<<\ break; case 'g':

cout<<\ }

return 0; }

//ex.6.4

#include const int strsize=20;

struct bop{

char fullname[strsize]; char title[strsize]; char bopname[strsize]; int preference; };

int main() {

using namespace std;

cout<<\ <<\ <<\ <<\ char ch; bop member[5]={

{\

{\

{\ {\ {\

};

cout<<\ while(cin>>ch&&ch!='q') {

switch(ch) {

case 'a':

for(int i=0;i<5;i++)

cout<

for(int i=0;i<5;i++)

cout<

for(int i=0;i<5;i++)

cout<

for(int i=0;i<5;i++) {

if(member[i].preference==0) cout<

break;

}

cout<<\ }

cout<<\ return 0; }

//ex.6.5

#include int main()

{

using namespace std;

double income,revenue;

cout<<\请输入你的收入:\ while(cin>>income&&income>=0) {

if(income<=5000) revenue=0.0;

else if(income<=15000) revenue=0.1*(income-5000); else if(income<=35000)

revenue=0.1*(15000-5000)+0.15*(income-15000); else

revenue=0.1*(15000-5000)+0.15*(35000-15000)+0.2*(income-35000);

cout<<\你的所得税为\ cout<<\请输入你的收入:\ }

return 0; }

//ex.6.6

#include #include using namespace std; struct patron{ string name; double money; };

int main() {

int num,temp=0;

cout<<\请输入捐款的人数:\ cin>>num; cin.get();

c++-primer-plus(第六版)第二至第六章课后编程练习全部答案.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c6zd7e9tdla9ersa9pruq6ksx797jw500wme_6.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top