acmLearn程序填空练习题答案atmaster·jindongwangacmLearn.doc

acmLearn程序填空练习题答案atmaster·jindongwangacmLearn.doc

  1. 1、本文档共65页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
acmLearn程序填空练习题答案atmaster·jindongwangacmLearn

Skip to content Features Business Explore Marketplace Pricing This repository Sign in orSign up · Watch 1 · Star 3 · Fork 3 jindongwang/acmLearn Code Issues0 Pull requests0 Projects 0 Pulse Graphs Permalink Switch branches/tags · Branches · Tags master Nothing to show Nothing to show Find file acmLearn/练习题/程序填空练习题答案.doc Fetching contributors… Cannot retrieve contributors at this time Raw Blame History executable file2292 lines (2283 sloc) 61.8 KB 【编写程序题参考答案】 【4.1】参考答案: #include stdio.h main( ) { int year; float money,rate,total; /* money:本金 rate:月利率 total:本利合计*/ printf(Input money and year =?); scanf(%f%d, money, year); /* 输入本金和存款年限 */ if(year==1) rate=0.00315; /* 根据年限确定利率 */ else if(year==2) rate=0.00330; else if(year==3) rate=0.00345; else if(year==5) rate=0.00375; else if(year==8) rate=0.00420; else rate=0.0; total=money + money * rate * 12 * year; /* 计算到期的本利合计 */ printf( Total = %.2f\n, total); } 【4.2】参考答案: #include stdio.h main( ) { int year, month, days; printf(Enter year and month:); scanf(%d%d, year, month); switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: days=31; break; /* 处理大月 */ case 4: case 6: case 9: case 11: days=30; break; /* 处理小月 */ case 2: if(year%4==0year%100!=0 || year%400==0) days=29; /* 处理闰年平月 */ else days=28; /* 处理不是闰年平月 */ break; default: printf(Input error!\n); /* 月份错误 */ days=0; } if( days!=0 ) printf(%d, %d is %d days\n, year, month, days); } 【4.3】参考答案: #include stdio.h main ( ) { float data1, data2; /* 定义两个操作数变量 */ char op; /* 操作符 */ printf(Enter your expression:); scanf(%f%c%f, data1, op, data2); /* 输入表达式 */ switch(op) /* 根据操作符分别进行处理 */ { case + : /* 处理加法 */ printf(%.2f+%.2f=%.2f\n, data1, data2, data1+data2); break; case - : /* 处理减法 */ printf(%.2f-%.2f=%.2f\n, data1, data2, data1-data2); break; case * : /* 处理乘法 */ printf(%.2f*%.2f=%.2f\n, data1, data2, data1*data2); break; case / : /* 处理除法 */ if( data2==0 ) /* 若除数为0 */ print

您可能关注的文档

文档评论(0)

2105194781 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档