哈工大C语言实验题.docx
《哈工大C语言实验题.docx》由会员分享,可在线阅读,更多相关《哈工大C语言实验题.docx(62页珍藏版)》请在优知文库上搜索。
1、Q508.(10分)第5章试验2:体型推断。医务工作者经广泛的调杳和统计分析,侬据身高与体重因索给出了以下按“体指数”进行体型推断的方法。体指数计算公式是:t=w/(h*h)其中:t是体指数;W是体重,其单位为千克;h是身高,其单位为米。依据给定的体指数t计克公式,可推断你的体重属于何种类型:当t18时,为低体重;当】8Vt25时,为正常体重;当25t27时,为超重体重;当t27时,为肥胖。*输入提示信息格式:“P1.easeenterh,w:n*输入数据格式要求:”f,%f(先读入身高,再读入体重,身高以米读入,体重以千克读入)*输出数据格式要求:当t18时,输出:1.owerweight!
2、n当18t25时,输出:StandardWeight1.n当25t27时,输出:-Higherweight!n-当t27时,输出:Tfat!n/inc1.ude#inc1.udemain()f1.oatt,w,h;printf(P1.easeenterh,w:n);scanf(%f,%f,&h,&w);t=w(h*h);if(t=18&t=25&t27)printf(Higherweight!n);e1.seprintf(Toofat!n);return0;Q586.10分)编写一个程序,输入年份和月份,推断该年是否是闰年,并依据给出的月份推断是什么季节和该月有多少天?(闰年的条件是年份能被4
3、整除但不能被100整除,或者能被40。整除;规定35月为春季,68月为豆季,911月为秋季,1、2和12月为冬季)。*输入格式要求:d,%d”提示信息:P1.easeenteryear,month:*输出格式要求:%dis1.eapyearn%disnot1.eapyearnTheseasonisspring/summer/autumn/winterThenumberofdaysofthismonthis%dn程序运行示例如下:实例1:P1.easeenteryear,month:2012,112012is1.eapyearTheseasonisautumnThenumberofdaysoft
4、hismonthis30实例2:P1.easeenteryear,month:2013,122013isnot1.eapyearTheseasoniswinterThenumberofdaysofthismonthis31#inc1.ude#inc1.udemain()intyear=。,1.eap=。,mon=0,day=。;printf(P1.caseenteryear,month:);scanf(%d,%d,&year,&mon);if(year%100!=0&.&year%4=0)I(year%100=08&year%400=O)printf(%dis1.eapyearn,year);
5、1.eap=1.;e1.seprintf(%disnot1.eapyearn,year);switch(mon)case 1:case 2:case12:printf(Theseasoniswintern);break;case 3:case 4:case5:printf(Theseasonisspringn);break;case 6:case 7:case8:printf(Theseasonissummern);break;case 9:case 10:case11.:printf(Theseasonisautumnn);break;switch(mon)case1:case3:case5
6、:case 7:case 8:case10:case12:day=31;break;case4:case6:case9:case11:day=30;break;case2:if(1.eap=1.)day=29;e1.seday=28;printf(Thenumberofdaysofthismonthis%dn,day);03161.(10分)请用e1.seif多分支条件推断语句编程设计一个简洁的计算器程序。要求:请用户按以下形式从键盘输入表达式:操作数运算符QP操作数然后计算表达式的值*输入提示信息*:无*输入数据格式*:%f%c%r*输出数据格式*:-%.2f%c%.2f=%.2fn若若输入
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 哈工大 语言 实验
