Last active
November 23, 2023 08:47
-
-
Save juanfal/63e73d7c196f54c1b64543c896b270df to your computer and use it in GitHub Desktop.
struct handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// t12e04.TPatient.cpp | |
// juanfc 2023-11-23 | |
// | |
#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