Last active
February 20, 2019 00:29
-
-
Save mneko22/df55d0595567a253c41c5154d809cedd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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