Skip to content

Instantly share code, notes, and snippets.

@juanfal
Last active November 23, 2023 08:48
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/3048d6695b4bdcdfd0419a25957a46b1 to your computer and use it in GitHub Desktop.
Save juanfal/3048d6695b4bdcdfd0419a25957a46b1 to your computer and use it in GitHub Desktop.
TStudent
// t12e05.TStudent.cpp
// juanfc 2023-11-23
//
#include <iostream>
#include <array>
using namespace std;
const int MAXNOSBJ = 50;
typedef array<int,MAXNOSBJ> TSubjects;
typedef array<float,MAXNOSBJ> TMarks;
struct TStudent {
string ID;
TSubjects subject;
TMarks mark;
int nSubjects;
};
float minGrade(TStudent st)
{
float min = st.mark[0];
for (int i = 1; i < st.nSubjects; ++i)
if (st.mark[i] < min)
min = st.mark[i];
return min;
}
bool overMark(TStudent st, int mark)
{
int i = 0;
while (i < st.nSubjects and st.mark[i] >= mark)
++i;
return i == st.nSubjects;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment