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

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

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

  • 62 次阅读
  • 3 次下载
  • 2025/6/13 22:09:04

1.

#include

usingnamespacestd;

doubleave(double x, double y); //调和平均数

intmain() {

doublei, j;

cout<<\; cin>>i>>j ;

double value = ave(i, j); //调用调和平均数

cout<<\<< value <

doubleave(double x, double y) {

double sum = 0.0; double a, b;

if ((x == 0) || (y == 0)) cout<<\<

sum = (2.0) * x * y / (x + y); cout<<\; cin>> a >> b; }

return (sum); }

2.

#include

usingnamespacestd;

constintArSize = 10;

intinput(int arr1[], int max);

1

void show (int arr2[], int n); doubleave (int arr3[], int m);

intmain() {

int score[ArSize];

int size = input(score, ArSize);

show(score,size);

double average = ave (score,size);

cout<<\<< average <

return 0; }

intinput(int arr1[], int max) {

inti = 0; int temp;

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

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

cin.clear();

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

elseif (temp < 0) break;

arr1[i] = temp; }

returni; }

void show (int arr2[], int n) {

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

cout<<\<

2

doubleave (int arr3[], int m) {

int ava = 0;

for (inti = 0 ; i< m; i++)

ava = ( ava + arr3[i] ) / m ; return (ava); }

3. a)

#include

usingnamespacestd;

struct box {

char maker[40]; float height; float width; float length; float volume; };

void show(box b);

int main() {

box boxx = {\, 23.9, 54354, 54.2, 4535.6 }; show(boxx); return 0; }

void show(box b) {

cout<<\<

3

b)

#include

usingnamespacestd;

struct box {

char maker[40]; float height; float width; float length; float volume; };

void show(box *b);

int main() {

box boxx = {\, 10.2, 10.0, 10.0}; show( &boxx); return 0; }

void show(box *b) {

b->volume = b->height * b->width * b->length ; cout<<\<

cout<<\<< b->maker <height <width <length <volume <

c)

#include

usingnamespacestd;

struct box {

char maker[40]; float height;

4

搜索更多关于: C++PrimerPlus第六版课后题第七章 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

1. #include usingnamespacestd; doubleave(double x, double y); //调和平均数 intmain() { doublei, j; cout<>i>>j ; double value = ave(i, j); //调用调和平均数 cout<<\<< value <

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价: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