Last active
December 4, 2016 08:04
-
-
Save iamarkdev/9302207e5d54bac097ebff0eb050ce06 to your computer and use it in GitHub Desktop.
Expand shorthand inputs (I.E a-z becomes a b c d ... x y z, etc)
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
#include <stdio.h> | |
int main() { | |
int c; | |
char line[] = ""; | |
for (int i = 0; (c = getchar()) != EOF; i++) { | |
line[i] = c; | |
if (c == '\n') { | |
i = -1; // ++ will set this back to 0, probably a better way? | |
line[0] = '\0'; | |
continue; | |
} | |
if (i < 2) { | |
continue; | |
} | |
if (line[i - 1] == '-') { | |
int end = line[i]; | |
for (int pos = line[i - 2]; pos <= end; pos++) { | |
printf("%c\n", pos); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment