Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
struct handling
// t11e04.TPatient.cpp
// juanfc 2022-01-16
//
#include <iostream>
#include <array>
using namespace std;
const int NBLOPRE = 24*31;
const int MAXGEN = 1000;
typedef array<int,NBLOPRE> TBloodPres;
typedef array<float,MAXGEN> TGenExpress;
struct TPatient {
string ID;
TBloodPres bloodPress;
TGenExpress genExpress;
int nGenEx;
};
int maxBloodPress(TPatient p)
{
int max = p.bloodPress[0];
for (int i = 1; i < NBLOPRE; ++i)
if (p.bloodPress[i] > max)
max = p.bloodPress[i];
return max;
}
void maxBloodPressDate(TPatient p, int& day, int& hour)
{
day = hour = 0;
for (int i = 1; i < NBLOPRE; ++i)
if (p.bloodPress[i] > p.bloodPress[day*24+hour]) {
day = i / 24;
hour = i % 24;
}
}
int timesBPOver(TPatient p, int threshold)
{
int cnt = 0;
for (int i = 0; i < NBLOPRE; ++i)
if (p.bloodPress[i] >= threshold)
++cnt;
return cnt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment