ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:18.47KB ,
资源ID:22100334      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/22100334.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C PRIMER PLUS 第七八正确答案Word文档下载推荐.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C PRIMER PLUS 第七八正确答案Word文档下载推荐.docx

1、n return 0;PE 7-2 int count = 0;inuput a string,and this program will out it and ASCII n(# to quit).n if(ch = ) printf(ninput another string(# to quit): n continue; while (count = 8) count = 0; printf(%c,%d ,ch,ch); count+;nBye!PE 7-3int main(void) int n; double sumeven = 0.0; int ct_even = 0; doubl

2、e sumodd = 0.0; int ct_odd = 0; while (scanf(%d, &n) = 1 & n != 0) if (n % 2 = 1) sumodd += n; +ct_odd; else sumeven += n; +ct_even;Number of evens: %d, ct_even); if (ct_even 0) average: %g, sumeven / ct_even); putchar(Number of odds:, ct_odd); if (ct_odd , sumodd / ct_odd);ndonenPE 7-4 int ex_c,pe_

3、c; ex_c = pe_c = 0;inuput a string,and this program will switch . to ! and ! to ! n(# to quit).n. pe_c+; else if (ch = ex_c+;%c,ch);nthere are %d pe switching and %d ex switching,pe_c,ex_c);PE 7-5 int ct1 = 0; int ct2 = 0; switch(ch) case : +ct1; break; +ct2; default : putchar(ch);%d replacements of

4、 . with !, ct1);%d replacements of ! with !, ct2);PE 7-6int main (void) int e_c,i_c,st_c; e_c = i_c = st_c = 0;input your string and this program will output the countn(# to quit): while(ch = getchar() !) /当输入ei 时 st_c =10,i_c = 10 if(ch !i) /当输入ie时st_c =10,i_c =1,输入其他字符st_c = 2 st_c = 2; if(ch = e

5、st_c = 10; i_c = 1; i_c = 10; if(st_c = i_c) /防止eii的bug e_c+; st_c = 1;nthere is %d ei in your string!nbye!,e_c);PE 7-7#define BASEPAY 10 /* $10 per hour */#define BASEHRS 40 /* hours at basepay */#define OVERTIME 1.5 /* 1.5 time */#define AMT1 300 /* 1st rate tier */#define AMT2 150 /* 2st rate tie

6、r */#define RATE1 0.15 /* rate for 1st tier */#define RATE2 0.20 /* rate for 2nd tier */#define RATE3 0.25 /* rate for 3rd tier */ double hours; double gross; double net; double taxes;Enter the number of hours worked this week: scanf(%lfhours); if (hours = BASEHRS) gross = hours * BASEPAY; gross = B

7、ASEHRS * BASEPAY + (hours - BASEHRS) * BASEPAY * OVERTIME; if (gross = AMT1) taxes = gross * RATE1; else if (gross int main(void) int choose; int test = 1;*nEnter the number corresponding to the desired pay rate or action:1) $8.75/hrtt2) $9.33/hrn3) $10.00/hrtt4) $11.20/hrn5) quitn while( (scanf(,&c

8、hoose) = 1) switch(choose) case 1: hours = 8.75; break; case 2: hours = 9.33; case 3: hours = 10.00; case 4: hours = 11.20; case 5: test = 0; default: test = 2; printf(error! try again: if(test = 2) test = 1; if(test = 1 ) if (hours gross = hours * BASEPAY; else gross = BASEHRS * BASEPAY + (hours -

9、BASEHRS) * BASEPAY * OVERTIME; if (gross taxes = gross * RATE1; else if (gross for (num = 2; num = lim; num+) for (div = 2, prime = YES; (div * div) = num; div+) if (num % div = 0) prime = NO; /* number is not prime */ if (prime = YES)%ld is prime.n, num);Please enter another limit;PE 7-11 const dou

10、ble price_artichokes = 1.25; const double price_beets = 0.65; const double price_carrots = 0.89; const double DISCOUNT_RATE = 0.05; double lb_artichokes; double lb_beets; double lb_carrots; double lb_total; double cost_artichokes; double cost_beets; double cost_carrots; double cost_total; double fin

11、al_total; double discount; double shipping;Enter a to buy artichokes, b for beets, c for carrots, q to quit:q & ch !Q if (ch = continue; while (getchar() ! ch = tolower(ch); switch (ch)aEnter pounds of artichokes:lb_artichokes);bEnter pounds of beets:lb_beets);cEnter pounds of carrots:lb_carrots);%c

12、 is not a valid choice.n cost_artichokes = price_artichokes * lb_artichokes; cost_beets = price_beets * lb_beets; cost_carrots = price_carrots * lb_carrots; cost_total = cost_artichokes + cost_beets + cost_carrots; lb_total = lb_artichokes + lb_beets + lb_carrots; if (lb_total shipping = 0.0; else i

13、f (lb_total 100.0) discount = DISCOUNT_RATE * cost_total; discount = 0.0; final_total = cost_total + shipping - discount;Your order:%.2f lbs of artichokes at $%.2f per pound:$ %.2fn, lb_artichokes, price_artichokes, cost_artichokes);%.2f lbs of beets at $%.2f per pound: lb_beets, price_beets, cost_b

14、eets);%.2f lbs of carrots at $%.2f per pound: lb_carrots, price_carrots, cost_carrots);Total cost of vegetables:, cost_total); 100)Volume discount:, discount);Shipping:, shipping);Total charges:, final_total);Chapter 8PE 8-1/Ctrl + z 结束文件 int ch; int ct = 0;= EOF) ct+;%d characters readn, ct);PE 8-3

15、/* Programming Exercise 8-3 */* Using ctype.h eliminates need to assume ASCII coding */ int uct = 0; int lct = 0; if (isupper(ch) uct+; else if (islower(ch) lct+;%d uppercase characters readn, uct);%d lowercase characters readn, lct);/* or you could use if (ch A ch z*/PE 8-5/* Programming Exercise 8-5 */* binaryguess.c - an improved number-guesser */ int high = 100; int low = 1; int guess = (high + low) / 2; char response;Pick an integer from 1 to 100. I will try to guess it.nRespond with a y if my guess is right, withna h if it is high, and with an l if it is low.nUh.is your number

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1