7-115 3206 化验诊断

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using pii = std::pair<i32, i32>;
using pll = std::pair<i64, i64>;
using vi = std::vector<i32>;
using vll = std::vector<i64>;
using vpii = std::vector<pii>;
using vpll = std::vector<pll>;

void solve();

int main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}

enum class Sex
{
    Male,
    Female
};

bool is_WBC_normal(double WBC)
{
    return (4 <= WBC && WBC <= 10);
}

bool is_RBC_normal(double RBC)
{
    return (3.5 <= RBC && RBC <= 5.5);
}

bool is_HGB_normal(double HGB, Sex sex)
{
    if (sex == Sex::Male)
    {
        return (120 <= HGB && HGB <= 160);
    }
    else
    {
        return (110 <= HGB && HGB <= 150);
    }
}

bool is_HCT_normal(double HCT, Sex sex)
{
    if (sex == Sex::Male)
    {
        return (42 <= HCT && HCT <= 48);
    }
    else
    {
        return (36 <= HCT && HCT <= 40);
    }
}

bool is_PLT_normal(double PLT)
{
    return (100 <= PLT && PLT <= 300);
}

int test_all(Sex sex, double WBC, double RBC, double HGB, double HCT, double PLT)
{
    i32 count{0};
    if (!is_WBC_normal(WBC))
    {
        ++count;
    }
    if (!is_RBC_normal(RBC))
    {
        ++count;
    }
    if (!is_HGB_normal(HGB, sex))
    {
        ++count;
    }
    if (!is_HCT_normal(HCT, sex))
    {
        ++count;
    }
    if (!is_PLT_normal(PLT))
    {
        ++count;
    }
    return count;
}

void solve()
{
    i32 k;
    std::cin >> k;
    bool endl = false;
    for (i32 i = 1; i <= k; ++i)
    {
        if (endl)
        {
            std::cout << '\n';
        }
        std::string str;
        std::cin >> str;
        Sex sex;
        if (str == "male")
        {
            sex = Sex::Male;
        }
        else
        {
            sex = Sex::Female;
        }
        double a, b, c, d, e;
        std::cin >> a >> b >> c >> d >> e;
        i32 res = test_all(sex, a, b, c, d, e);
        if (res == 0)
        {
            std::cout << "normal";
        }
        else
        {
            std::cout << res;
        }
        endl = true;
    }
}
posted @ 2025-10-13 16:33  TPPPP72  阅读(7)  评论(0)    收藏  举报