Skip to content

Instantly share code, notes, and snippets.

@alecGraves
Created August 24, 2017 04:29
Show Gist options
  • Save alecGraves/d5ab8f1c669a821e244f0a26ca6f65d1 to your computer and use it in GitHub Desktop.
Save alecGraves/d5ab8f1c669a821e244f0a26ca6f65d1 to your computer and use it in GitHub Desktop.
Tiny Student Struct for MTRE 2610
struct Student {
int n, c[9], g[9];
void SetGrades(int *C, char *G, int N){
for (int i(0); i < N; ++i){
AddGrade(C[i], G[i]);
}
}
void AddGrade(int C, char G){
c[n] = C;
g[n++] = G;
}
double GetGPA(){
int h(0), w(0);
for (int i(0); i < n; ++i){
if(g[i] < 69) w += (69-g[i])*c[i];
h += c[i];
}
return (float)w / h;
}
Student() :n(0) {}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment