哈工大c语言第八章实验答案,哈工大C语言实验题.doc

62e50291a81fc54b507f33cb80033297.gif 哈工大C语言实验题.doc

(53页)

7195ccdded8ed51dc6f834a2efbe80b4.gif

本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦!

14.90 积分

窗体顶端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&&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,112012 is leap yearThe season is autumnThe number of days of this month is 30实例2:Please enter year,month:2013,122013 is not leap yearThe season is winterThe 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:");     scanf("%d,%d",&year,&mon);       if((year%100!=0&&year%4==0)||(year%100==0&&year%400==0)){         printf("%d is leap year\n",year);         leap=1;     }     else        printf("%d is not leap year\n",year);       switch(mon)     {         case  1:         case  2:         case 12:printf("The season is winter\n");                 break;         case  3:         case  4:         case  5:printf("The season is spring\n");                 break;         case  6:         case  7:         case  8:printf("The season is summer\n");                 break;         case  9:         case 10:         case 11:printf("The season is autumn\n");                 break;     }       switch(mon)     {         case  1:         case  3:         case  5:         case  7:         case  8:         case 10:         case 12:day=31;                 break;         case  4:         case  6:         case  9:         case 11:day=30;                 break;         case  2:             if(leap==1)                 day=29;             else                day=28;     }     printf("The number of days of this month is %d\n",day); }窗体顶端Q3161.(10分)请用else if多分支条件判断语句编程设计一个简单的计算器程序。要求:(1)请用户按以下形式从键盘输入表达式:操作数① 。省略部分。    score[j]=temp1,id[j]=temp2;             }     for(i=1;i<=n;i++)         printf("%ld\t%.0f\n",id[i],score[i]);     goto Choice;   d:     printf("Sort in ascending order by number:\n");     for(i=1;i

524d6daf746efaa52c3c71bbfe7ba172.gif  天天文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值