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

当前位置:首页 > C primer plus(第6版)中文版编程练习答案第15章

C primer plus(第6版)中文版编程练习答案第15章

  • 62 次阅读
  • 3 次下载
  • 2025/5/22 19:27:16

channel = maxchannel; }

void Tv::settings()const { cout << \ if (state == On) { cout << \ cout << \ cout << \ cout << \ } }

//use_tv.cpp #include \int main() { Tv s42; Remote grey; grey.mode_show(); cout << \ s42.settings(); s42.onoff(); s42.chanup(); cout << \ s42.settings(); s42.set_rmode(grey); grey.set_chan(s42, 10); grey.volup(s42); grey.volup(s42); cout << \ s42.settings(); Tv s58(Tv::On); s58.set_mode(); grey.set_chan(s58, 28); cout << \ s58.settings(); s58.set_rmode(grey); system(\ return 0; }

2、

//exc_mean.h

#ifndef EXC_MEAN_H_ #define EXC_MEAN_H_ #include #include #include #include using namespace std;

class bad_hmean :public logic_error {

private: string name; public: explicit bad_hmean(const string &n = \ string mesg(); virtual ~bad_hmean()throw(){} };

bad_hmean::bad_hmean(const string &n, const string &s) :name(n), logic_error(s) { }

inline string bad_hmean::mesg() { return \}

class bad_gmean :public logic_error {

private: string name; public: explicit bad_gmean(const string &n = \ string mesg(); virtual ~bad_gmean()throw(){} };

bad_gmean::bad_gmean(const string &n, const string &s) :name(n), logic_error(s) {

}

inline string bad_gmean::mesg() { return \}

#endif //error.cpp

#include \

double hmean(double a, double b); double gmean(double a, double b);

int main() { double x, y, z; cout << \ while (cin >> x >> y) { try{ z = hmean(x, y); cout << \ << \ cout << \ << \ cout << \ } catch (bad_hmean &bg) { cout << bg.what(); cout << \ cout << \ continue; } catch (bad_gmean &hg) { cout << hg.what(); cout << \ cout << \ break; } } cout << \

system(\ return 0; }

double hmean(double a, double b) { if (a == -b) throw bad_hmean(); return 2.0*a*b / (a + b); }

double gmean(double a, double b) { if (a < 0 || b < 0) throw bad_gmean(); return sqrt(a*b); }

3、

//exc_mean.h

#ifndef EXC_MEAN_H_ #define EXC_MEAN_H_ #include #include #include #include using namespace std;

class bad_hmean :public logic_error {

private: string name; public: double v1; double v2; explicit bad_hmean(double a = 0, double b = 0, const string &s = \ void mesg(); virtual ~bad_hmean()throw(){} };

bad_hmean::bad_hmean(double a, double b, const string &s) :v1(a), v2(b), logic_error(s) {

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

channel = maxchannel; } void Tv::settings()const { cout << \ if (state == On) { cout << \ cout << \ cout << \ cout << \ } } //use_tv.cpp #include \int main() { Tv s42; Remote grey; grey.mode_show(); cout << \ s42.settings(); s42.onoff(); s42.chanup(); cout << \ s42.settings(); s42.set_rmode(grey); grey.set_chan(s42, 10); grey.volup(s42); grey.volup(s42); co

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