Last active
August 29, 2015 13:56
-
-
Save prehistoricpenguin/9343256 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
| string generate_code() { | |
| const int kcodelength = 25; | |
| char res[kcodelength + 10]; | |
| string buffer = "1234567890abcdefghijklmnopqrstuvwzyz" | |
| "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
| int len = buffer.length(); | |
| int idx = 0; | |
| for (int i = 0; i < kcodelength; ++i) { | |
| char tmp = buffer[rand() % len]; | |
| res[idx++] = tmp; | |
| if (!((idx + 1) % 6) && i != kcodelength - 1) | |
| res[idx++] = '-'; | |
| } | |
| res[idx] = '\0'; | |
| return res; | |
| } | |
| int main() | |
| { | |
| int num = 10; | |
| srand(time(NULL)); | |
| while (num--) { | |
| cout << generate_code() << endl; | |
| } | |
| return 0; | |
| } | |
| /* | |
| Frupq-jb6BI-wyaTV-Y4Di5-fQBX2 | |
| hHGvt-BzZJT-3zre4-C8ipz-gJupX | |
| H9vUI-KAtTu-OOOYL-ttaH7-cZZlZ | |
| ebQUm-wWVgQ-eV67f-syQ37-bgz9c | |
| gyBzF-AGsRW-acdGN-9YQd3-RN7jP | |
| zttTj-72HCV-PSUgA-O1fR3-FYR2s | |
| dtV8S-guqri-OSsyn-PmtXN-Vzc8Y | |
| ZfNs0-9mzz3-DGoYf-CUSlC-eDh52 | |
| wBfWE-4KXhO-zbOzz-CCEGI-nmKmE | |
| Gg1Kh-QgmA5-bebBW-NUmFC-zrnjS | |
| Press any key to continue . . . | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment