Created
December 18, 2019 09:53
-
-
Save AmosAidoo/4c1fbdf7ec5dd916ef854dad219e212b to your computer and use it in GitHub Desktop.
This file contains 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
void _empty(int* Sk, int& T, int n) { | |
int groupCount = 0; | |
do { | |
//m will be the top-most item on the stack and on subsequent groups | |
int m = Sk[T]; | |
//Remove all m elements from the stack | |
T = T - m - 1; | |
groupCount += 1; | |
} while (T > 0); | |
cout << "The number of groups is " << groupCount << "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment