电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

哈工大C语言实验题

哈工大C语言实验题_第1页
1/53
哈工大C语言实验题_第2页
2/53
哈工大C语言实验题_第3页
3/53
Q308.(10 分)第5 章 实验2:体型判断。 医务工作者经广泛的调查和统计分析,根据身高与体重因素给出了以下按“体指数”进行体型判断的方法。体指数计算公式是: t = w /(h*h) 其中:t 是体指数;w 是体重,其单位为千克;h 是身高,其单位为米。根据给定的体指数 t 计算公式,可判断你的体重属于何种类型: 当 t<18 时,为低体重; 当 18≤t<25 时,为正常体重; 当 25≤t<27 时,为超重体重; 当 t≥27 时,为肥胖。 ****输入提示信息格式:"Please enter h,w:\n" ****输入数据格式要求:"%f,%f"(先读入身高,再读入体重,身高以米读入,体重以千克读入) ****输出数据格式要求: 当 t<18 时,输出:"Lower weight!\n" 当 18≤t<25 时,输出:"Standard weight!\n" 当 25≤t<27 时,输出:"Higher weight!\n" 当 t≥27 时, 输出:"Too fat!\n" #include #include main() { float t,w,h; printf("Please enter h,w:\n"); scanf("%f,%f",&h,&w); t = w/(h*h); if(t<18) printf("Lower weight!\n"); else if(t>=18&&t<25) printf("Standard weight!\n"); else if(t>=25&&t<27) printf("Higher weight!\n"); else printf("Too fat!\n"); return 0; } Q586.( 10 分)编写一个程序,输入年份和月份,判断该年是否是闰年,并根据给出的月份判断是什么季节和该月有多少天?(闰年的条件是年份能被4 整除但不能被100 整除,或者能被400 整除;规定3~5 月为春季,6~8 月为夏季,9~11 月为秋季,1、2 和12 月为冬季)。 **输入格式要求:"%d,%d" 提示信息:"Please enter year,month:" **输出格式要求:"%d is leap year\n" "%d is not leap year\n" "The season is spring/summer/autumn/winter" "The number of days of this month is %d\n" 程序运行示例如下: 实例 1: Please enter year,month:2012,11 2012 is leap year The season is autumn The number of days of this month is 30 实例 2: Please enter year,month:2013,12 2013 is not leap year The season is winter The number of days of this month is 31 #include #include main() { int year=0,leap=0,mon=0,day=0; printf("Please enter year,month:"); ...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

哈工大C语言实验题

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部