Created
September 16, 2013 06:54
-
-
Save henix/6577377 to your computer and use it in GitHub Desktop.
with sign
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
int getint2(int *out) { | |
register int s = 0; | |
register int ch; | |
ch = getchar(); | |
bool negative = false; | |
while (ch < '0' || ch > '9') { | |
if (ch == '-') { | |
negative = true; | |
ch = getchar(); | |
break; | |
} | |
ch = getchar(); | |
} | |
while (ch >= '0' && ch <= '9') { | |
s = s * 10 + ch - '0'; | |
ch = getchar(); | |
} | |
*out = negative ? -s : s; | |
return ch; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment