C语言程序设计现代方法第16章答案(3)

2021-02-21 12:24

struct shape scale(struct shape s, double c)

{ struct shape new_shape = s;

if (new_shape.shape_kind == RECTANGLE) {

new_shape.u.rectangle.height *= c;

new_shape.u.rectangle.width *= c;

} else

new_shape.u.circle.radius *= c;

return new_shape;

}

15. [was #14]

(a) enum week_days {MON, TUE, WED, THU, FRI, SAT, SUN};

(b) typedef enum {MON, TUE, WED, THU, FRI, SAT, SUN} Week_days;

17. [was #16] All the statements are legal, since C allows integers and

enumeration values to be mixed without restriction. Only (a), (d), and (e) are safe. (b) is not meaningful if i has a value other than 0 or 1. (c) will not yield a meaningful result if b has the value 1.

Answers to Selected Programming Projects

1. [was #6; modified]

#include <stdio.h>

#define COUNTRY_COUNT \

((int) (sizeof(country_codes) / sizeof(country_codes[0])))

struct dialing_code {

char *country;

int code;

};

const struct dialing_code country_codes[] =

{{"Argentina", 54}, {"Bangladesh", 880},

{"Brazil", 55}, {"Burma (Myanmar)", 95},

{"China", 86}, {"Colombia", 57},


C语言程序设计现代方法第16章答案(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:毛泽东思想和中国特色社会主义理论体系概论课后习题答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: