第一范文网 - 专业文章范例文档资料分享平台

哈工大C语言实验题

来源:用户分享 时间:2025/5/22 9:03:29 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

..

Q308.(10分)第5章 实验2:体型判断。

医务工作者经广泛的调查和统计分析,根据身高与体重因素给出了以下按“体指数”进行体型判断的方法。体指数计算公式是: t = w /(h*h)

其中:t是体指数;w是体重,其单位为千克;h是身高,其单位为米。根据给定的体指数t计算公式,可判断你的体重属于何种类型: 当 t<18 时,为低体重; 当 18≤t<25 时,为正常体重; 当 25≤t<27 时,为超重体重; 当 t≥27 时,为肥胖。

****输入提示信息格式:\

****输入数据格式要求:\(先读入身高,再读入体重,身高以米读入,体重以千克读入) ****输出数据格式要求:

当 t<18 时,输出:\ 当 18≤t<25 时,输出:\ 当 25≤t<27 时,输出:\ 当 t≥27 时, 输出:\

#include #include main() {

;.

..

float t,w,h;

printf(\

scanf(\

t = w/(h*h);

if(t<18)

printf(\

else if(t>=18&&t<25)

printf(\

else if(t>=25&&t<27) printf(\ else

printf(\

return 0; }

;.

..

Q586.(

10分)编写一个程序,输入年份和月份,判断该年是否是闰年,并根据给出的月份判断是什么季节和该月有多少天?(闰年的条件是年份能被4整除但不能被100整除,或者能被400整除;规定3~5月为春季,6~8月为夏季,9~11月为秋季,1、2和12月为冬季)。

**输入格式要求:\提示信息:\

**输出格式要求:\is spring/summer/autumn/winter\\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(\ scanf(\

if((year0!=0&&year%4==0)||(year0==0&&year@0==0)){ printf(\ leap=1; } else

printf(\

switch(mon) {

case 1: case 2:

case 12:printf(\ break; case 3: case 4:

case 5:printf(\ break;

;.

搜索更多关于: 哈工大C语言实验题 的文档
哈工大C语言实验题.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c6eg6c0l3k07f1wl0k4bu3bj0w6iip0013kd_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top