7-40 到底是不是太胖了(10 分)
據說一個人的標準體重應該是其身高(單位:釐米)減去100、再乘以0.9所得到的公斤數。真實體重與標準體重誤差在10%以內都是完美身材(即 | 真實體重 − 標準體重 | < 標準體重×10%)。已知市斤是公斤的兩倍。現給定一羣人的身高和實際體重,請你告訴他們是否太胖或太瘦了。
輸入格式:
輸入第一行給出一個正整數N
(≤ 20)。隨後N
行,每行給出兩個整數,分別是一個人的身高H
(120 < H < 200;單位:釐米)和真實體重W
(50 < W ≤ 300;單位:市斤),其間以空格分隔。
輸出格式:
爲每個人輸出一行結論:如果是完美身材,輸出You are wan mei!
;如果太胖了,輸出You are tai pang le!
;否則輸出You are tai shou le!
。
輸入樣例:
3
169 136
150 81
178 155
輸出樣例:
You are wan mei!
You are tai shou le!
You are tai pang le!
#include <stdio.h>
#include <math.h>
int main(){
int i,cls,num;
double StandWeight,height,weight;
scanf("%d",&num);
int hw[2*num];
for(i=0;i<num*2;i+=2){
scanf("%lf %lf",&height,&weight);
StandWeight = (height-100)* 1.8;//公斤
if(fabs(weight-StandWeight)<StandWeight*0.1){
cls = 3;
}
else if(StandWeight>weight&&fabs(StandWeight-weight)>=StandWeight*0.1){
cls = 2;
}
else if(fabs(weight-StandWeight)>StandWeight*0.1&&weight>=StandWeight){
cls = 1;
}
hw[i] = cls;
}
for(i=0;i<num*2;i+=2){
if(hw[i]==3){
printf("%s","You are wan mei!\n");
}
else if(hw[i]==1){
printf("%s","You are tai pang le!\n");
}
else if(hw[i]==2){
printf("%s","You are tai shou le!\n");
}
}
return 0;
}
這個自己寫的太過粗糙
看到個哥們寫的
- #include<cstdio>
- #include<cmath>
- using namespace std;
- int n,a,b,c;
- int main(){
- scanf("%d",&n);
- while(n--){
- scanf("%d%d",&a,&b);
- c = (a-100)*1.8;//標準體重
- if(abs(b-c)<(c*0.1)){
- printf("You are wan mei!\n");
- }
- if((abs(b-c)>=(c*0.1))&&b<c){
- printf("You are tai shou le!\n");
- }
- if((abs(b-c)>=(c*0.1))&&b>c){
- printf("You are tai pang le!\n");
- }
- }
- return 0;
- }