当前位置:网站首页>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;
}
边栏推荐
- What is the function of laravel facade
- Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
- 每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
- Demand delineation executive summary
- Microservice practice | teach you to develop load balancing components hand in hand
- Who is better for Beijing software development? How to find someone to develop system software
- Jd.com interviewer asked: what is the difference between using on or where in the left join association table and conditions
- AMQ 4043 solution for errors when using IBM MQ remote connection
- Methods of classfile
- 西瓜书--第六章.支持向量机(SVM)
猜你喜欢

Ora-12514 problem solving method

Flink-使用流批一体API统计单词数量

Micro service practice | introduction and practice of zuul, a micro service gateway

Say goodbye to 996. What are the necessary plug-ins in idea?

Jd.com interviewer asked: what is the difference between using on or where in the left join association table and conditions

知识点很细(代码有注释)数构(C语言)——第三章、栈和队列

MySQL multi column in operation

Matplotlib swordsman line - first acquaintance with Matplotlib

Probability is not yet. Look at statistical learning methods -- Chapter 4, naive Bayesian method

破茧|一文说透什么是真正的云原生
随机推荐
Complete solution of servlet: inheritance relationship, life cycle, container, request forwarding and redirection, etc
知识点很细(代码有注释)数构(C语言)——第三章、栈和队列
[staff] the lines and spaces of the staff (the nth line and the nth space in the staff | the plus N line and the plus N space on the staff | the plus N line and the plus N space below the staff | the
JVM指令助记符
洞见云原生|微服务及微服务架构浅析
Don't look for it. All the necessary plug-ins for Chrome browser are here
Taking the upgrade of ByteDance internal data catalog architecture as an example, talk about the performance optimization of business system
数构(C语言--代码有注释)——第二章、线性表(更新版)
Insight into cloud native | microservices and microservice architecture
分布式锁的这三种实现方式,如何在效率和正确性之间选择?
How to use PHP spoole to implement millisecond scheduled tasks
VIM操作命令大全
Customize redis connection pool
Redis zadd导致的一次线上问题排查和处理
微服务实战|手把手教你开发负载均衡组件
《统计学习方法》——第五章、决策树模型与学习(上)
Knife4j 2.X版本文件上传无选择文件控件问题解决
Knife4j 2. Solution to the problem of file control without selection when uploading x version files
概念到方法,绝了《统计学习方法》——第三章、k近邻法
机器学习之数据类型案例——基于朴素贝叶斯法,用数据辩男女