Skip to content

Instantly share code, notes, and snippets.

@juanfal
Last active November 23, 2023 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanfal/63e73d7c196f54c1b64543c896b270df to your computer and use it in GitHub Desktop.
Save juanfal/63e73d7c196f54c1b64543c896b270df to your computer and use it in GitHub Desktop.
struct handling
// 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