C++primer plus 7章—十章课后答案概要1.docx

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Cprimerplus7章—十章课后答案概要1

C++ Primer Plus(第六版)中文版编程练习第七章到第十八章答案7.7#includeiostreamdouble * fill_array( double * begin, double * end);voidshow_array( double * begin, double * end);void revalue(double factor , double * begin, double * end);using namespace std;int main(){double properties[5];double * endd=fill_array(properties,properties+5);show_array(properties,endd);double factor;coutenter revaluation factor: endl;cinfactor;revalue(factor,properties,endd);show_array(properties,endd);coutdone;return 0;}double * fill_array( double * begin, double * end) {int i;for( i=0;iend-begin;i++) {coutenter value #i+1 :endl;if(!(cin*(begin+i)))break; }double * endd=begin+i;returnendd; }voidshow_array( double * begin, double * end) { double * ps;int i; for( i=0,ps=begin;iend-begin;i++,ps++)coutvalue #i+1: *psendl; } void revalue(double fac , double * begin, double * end) { double * ps; for(ps=begin;ps!=end;ps++) { (*ps)*=fac; } }7.8a.#includeiostream#includestringconstint Seasons=4;using namespace std;const char* snames[4]={Spring,Summer,Fall,Winter};void fill(double * ps);void show(double * ps);int main(){double expense[4];fill( expense);show( expense);return 0;}void fill(double * ps){for(int i=0;iSeasons;i++){coutsnames[i] expense: ;cinps[i];}}void show(double * ps){double total=0;coutexpenseendl;for(int i=0;iSeasons;i++){coutsnames[i] expense: ps[i]endl;total+=ps[i];}couttotal expense :total;}b#includeiostream#includestringstruct inflatable{double expense[4];};inflatable expense1;constint Seasons=4;usingnamespacestd;constchar* snames[4]={Spring,Summer,Fall,Winter};void fill(inflatable *expense1);void show(inflatable expense1);int main(){fill( expense1);show( expense1);return 0;}void fill(inflatable *expense1){for(int i=0;iSeasons;i++){coutsnames[i] expense: ;cin(*expense1).expense[i];}}void show(inflatable expense1){double total=0;coutexpenseendl;for(int i=0;iSeasons;i++){coutsnames[i] expense: expense1.expense[i]endl;total+=expense1.expense[i];}couttotal expense :total;}7.9#includeiostreamusingnamespace

文档评论(0)

yaocen + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档