Created
July 12, 2017 11:29
-
-
Save timothy/8cbdd1b6ce4b5e74889f90cbc9b3020b to your computer and use it in GitHub Desktop.
circular count within a loop
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
//circular count within a loop example | |
std::string key = "12345"; | |
for (int i = 0, j = 0; i < 30; ++i) | |
{ | |
std::cout << j; | |
j = (int) ((j + 1) % key.length()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment