参考代码:
#include <bits/stdc++.h>
using namespace std;
using db = double;
char gender, exercise, diet;
db faHeight, moHeight;
signed main()
{
cin >> gender >> faHeight >> moHeight >> exercise >> diet;
db ans = gender == 'M' ? (faHeight + moHeight) * .54 : (faHeight * .923 + moHeight) / 2;
ans = ans * (1 + .02 * (exercise == 'Y') + .015 * (diet == 'Y'));
cout << ans;
return 0;
}