当前位置:网站首页>C语言之到底是不是太胖了
C语言之到底是不是太胖了
2022-07-02 06:34:00 【FF小迷糊吖~】
据说一个人的标准体重应该是其身高(单位:厘米)减去100、再乘以0.9所得到的公斤数。真实体重与标准体重误差在10%以内都是完美身材(即 | 真实体重 − 标准体重 | < 标准体重 × 10%)。现给定一群人的身高和实际体重,请你告诉他们是否太胖或太瘦了。
问题:
请根据题目要求,编写程序实现体重的判断。
编程要求:
1、 按照题目中给出要求进行体重判断,并借助printf函数输出结果;
2、 使用scanf函数进行数据的输入;
3、 请严格按照输出效果输出;(影响成绩评定)
4、任务提交代码时需保证其符合行业代码规范,需进行必要的缩进及换行。(影响成绩评定)
运行效果1:
请输入身高体重信息,身高(厘米)体重(公斤):171 65
您是标准体重!
请按任意键继续. . .
运行效果2:
请输入身高体重信息,身高(厘米)体重(公斤):171 77
您太胖了!
请按任意键继续. . .
运行效果3:
请输入身高体重信息,身高(厘米)体重(公斤):160 46
您太瘦了!
请按任意键继续. . .
#include <stdio.h>
int main(void)
{
double H ,W ,result;
printf("请输入身高体重信息,身高(厘米)体重(公斤):");
scanf("%lf%lf", &H ,&W);
result = (H - 100) * 0.9;
if(W >= result * 1.1 )
printf("您太胖了!\n");
else if(W <= result * 0.9)
printf("您太瘦了!\n");
else
printf("您是标准体重!\n");
return 0;
}
#include <stdio.h>
int main(void)
{
double h,w,a;
printf("请输入身高体重信息,身高(厘米)体重(公斤):");
scanf("%d %d",&h,&w);
a=(h-100)*0.9;
if(w-a>=0){
if((w-a)<a*0.1){
printf("您是标准体重!\n");
} else if((w-a)>=a*0.1){
printf("您太胖了!\n");
}
} else{
if((a-w)<a*0.1){
printf("您是标准体重!\n");
} else if((a-w)>=a*0.1){
printf("您太瘦了!\n");
}
}
return 0;
}
边栏推荐
- Redis zadd导致的一次线上问题排查和处理
- web安全与防御
- What are the waiting methods of selenium
- Enterprise level SaaS CRM implementation
- 微服务实战|Eureka注册中心及集群搭建
- Matplotlib剑客行——容纳百川的艺术家教程
- 每天睡觉前30分钟阅读_day3_Files
- Statistical learning methods - Chapter 5, decision tree model and learning (Part 1)
- Matplotlib swordsman line - first acquaintance with Matplotlib
- 盘点典型错误之TypeError: X() got multiple values for argument ‘Y‘
猜你喜欢
MySQL事务
Mysql默认事务隔离级别及行锁
每天睡觉前30分钟阅读_day4_Files
微服务实战|手把手教你开发负载均衡组件
Programmers with ten years of development experience tell you, what core competitiveness do you lack?
【Go实战基础】gin 如何绑定与使用 url 参数
Microservice practice | load balancing component and source code analysis
[go practical basis] how to bind and use URL parameters in gin
idea查看字节码配置
定时线程池实现请求合并
随机推荐
The channel cannot be viewed when the queue manager is running
十年开发经验的程序员告诉你,你还缺少哪些核心竞争力?
Jd.com interviewer asked: what is the difference between using on or where in the left join association table and conditions
聊聊消息队列高性能的秘密——零拷贝技术
【Go实战基础】gin 如何设置路由
"Interview high frequency question" is 1.5/5 difficult, and the classic "prefix and + dichotomy" application question
MySQL multi column in operation
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
Chrome browser plug-in fatkun installation and introduction
记录下对游戏主机配置的个人理解与心得
zk配置中心---Config Toolkit配置与使用
「Redis源码系列」关于源码阅读的学习与思考
Redis installation and deployment (windows/linux)
每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
Programmers with ten years of development experience tell you, what core competitiveness do you lack?
Cloudreve自建云盘实践,我说了没人能限制得了我的容量和速度
【Go实战基础】gin 如何获取 GET 和 POST 的请求参数
Flink-使用流批一体API统计单词数量
Machine learning practice: is Mermaid a love movie or an action movie? KNN announces the answer
Cloudrev self built cloud disk practice, I said that no one can limit my capacity and speed