Skip to content

Instantly share code, notes, and snippets.

@mneko22
Last active February 20, 2019 00:29
Show Gist options
  • Select an option

  • Save mneko22/df55d0595567a253c41c5154d809cedd to your computer and use it in GitHub Desktop.

Select an option

Save mneko22/df55d0595567a253c41c5154d809cedd to your computer and use it in GitHub Desktop.
class StudentSpec {
public:
int math;
int english;
StudentSpec *next;
StudentSpec(int english, int math, StudentSpec *next) {
this->english = english;
this->math = math;
this->next = next;
}
void addList(StudentSpec *next) {
this->next = next;
}
void removeNext() {
delete this->next;
this->next = nullptr;
}
~StudentSpec() {
this->removeNext();
}
};
StudentSpec loadData() {
}
double getMathAverage(StudentSpec* student, double sum, int count) {
if (student->next == nullptr) {
return sum/count;
}
return getMathAverage(student->next, sum + student->math, count++);
}
int main() {
StudentSpec *specList = new StudentSpec(12, 23, nullptr);
int mathAve = getMathAverage(specList, 0, 1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment