云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C++PrimerPlus第六版课后题第七章

C++PrimerPlus第六版课后题第七章

  • 62 次阅读
  • 3 次下载
  • 2025/6/13 22:11:29

cout<<\<< size <

Show_array(ps, num);

Reverse_array(ps, num); Show_array(ps, num);

Reverse_array(ps + 1, num - 2); Show_array(ps, num);

deleteps;

return 0; }

intFill_array(double *arr, int n) {

inti = 0;

cout<<\ ;

while ( (i< n) && (cin>>arr[i])) i++; returni; }

voidShow_array(double *arr, int n) {

cout<<\<

cout<<\<

double * Reverse_array(double *arr, int n) {

double * temp= newdouble [n]; for (inti = 0; i< n; i++) temp[i] = arr[n-i-1]; for (inti = 0; i< n; i++) arr[i] = temp[i]; delete temp; returnarr; }

7.

#include

9

usingnamespacestd;

constint Max = 5;

double * Fill_array(doublear[], int limit); voidShow_array(constdoublear[], double * n); void revalue(double r, doublear[], double * n);

int main() {

double properties[Max];

double * address = Fill_array(properties, Max); Show_array(properties, address); if ((address - properties) > 0 ) {

cout<<\ ; double factor;

while (!(cin>> factor)) {

cin.clear();

while (cin.get() != '\\n') continue;

cout<<\ ; }

revalue(factor, properties, address); Show_array(properties, address); }

cout<<\<

double * Fill_array(doublear[], int limit) {

double temp; inti;

for (i = 0; i< limit; i++) {

cout<<\<> temp; if (!cin) {

10

cin.clear();

while (cin.get() != '\\n') continue;

cout<<\ ; break; }

elseif (temp < 0) break; ar[i] = temp; }

return (ar + i); }

voidShow_array(constdoublear[], double * n) {

for (inti = 0; i< (n - ar); i++)

cout<<\<

void revalue(double r, doublear[], double * n) {

for (inti = 0; i< (n - ar); i++) ar[i] *= r; }

8. a)

#include

usingnamespacestd;

constint seasons = 4;

constchar * arr[4] = {\, \, \, \}; voidfill(double * pa, int n);

voidshow(constdouble * pa, int n); intmain() {

doublear[seasons]; fill(ar, seasons); show(ar, seasons); return 0; }

11

voidfill(double * pa, int n) {

for(inti= 0; i< n; i++) {

cout<<\<> pa[i]; } }

voidshow(constdouble * pa, int n) {

double total = 0.0; cout<<\; for(inti = 0; i< n; i++) {

cout<

cout<<\<< total <

b)

#include

usingnamespacestd;

constint seasons = 4;

constchar * arr[4] = {\, \, \,

struct money {

double expense; };

voidfill(money * pa, int n);

voidshow(const money * pa, int n); intmain() {

money ar[seasons]; fill(ar, seasons); show(ar, seasons); return 0;

12

\};

搜索更多关于: C++PrimerPlus第六版课后题第七章 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com