int next_int() {
char c;
do { c = getchar(); } while( c != '-' && !isdigit(c) );
bool neg = (c == '-');
int result = neg ? 0 : c - '0';
while( isdigit(c = getchar()) )
result = 10 * result + (c - '0');
return neg ? -result : result;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter