当前位置:网站首页>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;
}
边栏推荐
- Number structure (C language -- code with comments) -- Chapter 2, linear table (updated version)
- 定时线程池实现请求合并
- 微服务实战|原生态实现服务的发现与调用
- 机器学习实战:《美人鱼》属于爱情片还是动作片?KNN揭晓答案
- JVM instruction mnemonic
- Chrome browser plug-in fatkun installation and introduction
- 【Go实战基础】gin 如何设置路由
- Microservice practice | declarative service invocation openfeign practice
- Double non undergraduate students enter the factory, while I am still quietly climbing trees at the bottom (Part 1)
- Matplotlib swordsman Tour - an artist tutorial to accommodate all rivers
猜你喜欢

企业级SaaS CRM实现

Chrome视频下载插件–Video Downloader for Chrome

Watermelon book -- Chapter 6 Support vector machine (SVM)

idea查看字节码配置

Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack

Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer

Ora-12514 problem solving method

Actual combat of microservices | discovery and invocation of original ecosystem implementation services

View the port of the application published by was

Matplotlib swordsman line - first acquaintance with Matplotlib
随机推荐
我服了,MySQL表500W行,居然有人不做分区?
Statistical learning methods - Chapter 5, decision tree model and learning (Part 1)
Alibaba /热门json解析开源项目 fastjson2
每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
Chrome browser tag management plug-in – onetab
Discussion on improving development quality and reducing test bug rate
记录下对游戏主机配置的个人理解与心得
Thinkphp5 how to determine whether a table exists
Microservice practice | Eureka registration center and cluster construction
数构(C语言)——第四章、矩阵的压缩存储(下)
Programmers with ten years of development experience tell you, what core competitiveness do you lack?
Troubleshooting and handling of an online problem caused by redis zadd
Watermelon book -- Chapter 6 Support vector machine (SVM)
深入剖析JVM是如何执行Hello World的
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
Double non undergraduate students enter the factory, while I am still quietly climbing trees at the bottom (Part 1)
长篇总结(代码有注释)数构(C语言)——第四章、串(上)
Microservice practice | teach you to develop load balancing components hand in hand
JVM指令助记符
Redis installation and deployment (windows/linux)