首页 > 代码库 > L1-031. 到底是不是太胖了

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. 到底是不是太胖了