1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
enum class bmi { weight, height };
int CalculateBMI( int weight, int height )
{
return (weight * 703) / (height * height);
}
int CalculateBMI( int weight, bmi h, int height )
{
if (h == bmi::height) return CalculateBMI( weight, height );
return 0;
}
int CalculateBMI( bmi a1, int v1, bmi a2, int v2 )
{
if (a1 == a2) return 0;
if (a1 == bmi::height) return CalculateBMI( v2, v1 );
return CalculateBMI( v1, v2 );
}
int main()
{
std::cout << "CalculateBMI( 123, 64 ) --> " << CalculateBMI( 123, 64 ) << "\n";
std::cout << "CalculateBMI( 123, bmi::height, 64 ) --> " << CalculateBMI( 123, bmi::height, 64 ) << "\n";
std::cout << "CalculateBMI( bmi::weight, 123, bmi::height, 64 ) --> " << CalculateBMI( bmi::weight, 123, bmi::height, 64 ) << "\n";
std::cout << "CalculateBMI( bmi::height, 64, bmi::weight, 123 ) --> " << CalculateBMI( bmi::height, 64, bmi::weight, 123 ) << "\n";
}
|