L1-031. 到底是不是太胖了
Posted diamondDemand
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了L1-031. 到底是不是太胖了相关的知识,希望对你有一定的参考价值。
#include <iostream>
#include <math.h>
using namespace std;
int isTooFat(float &a, float &b)
{
a = (a - 100) * 0.9 * 2;
//calculate the standard weight, unit is market jin
cout << a << endl;
cout << a*1.1 << endl;
if(fabs(a*0.9-b)<0.0000000001)
return -1;
if(fabs(a*1.1-b)<0.0000000001)
return 1;
if(a*0.9<b&&b<a*1.1)
return 0;
if(b<a*0.9)
return -1;
return 1;
}
int main()
{
int n;
float height, weight;
cin >> n;
int a[n];
for(int i=0; i<n; i++)
{
cin >> height >> weight;
a[i] = isTooFat(height, weight);
}
for(int i=0; i<n; i++)
{
switch (a[i])
{
case 0:
cout << "You are wan mei!\n";
break;
case 1:
cout << "You are tai pang le!\n";
break;
case -1:
cout << "You are tai shou le!\n";
break;
default:
break;
}
}
//cout << "Hello world!" << endl;
return 0;
}
以上是关于L1-031. 到底是不是太胖了的主要内容,如果未能解决你的问题,请参考以下文章