Skip to content

Instantly share code, notes, and snippets.

@tairov
Created March 27, 2014 15:48
Show Gist options
  • Save tairov/9810630 to your computer and use it in GitHub Desktop.
Save tairov/9810630 to your computer and use it in GitHub Desktop.
cpp, c++, c, read numbers
// Input sequence of numbers
while (1)
{
ch = getchar_unlocked();
if (ch == EOF)
{
// do something with N
break;
}
else if (ch == '\n')
{
// do something with N
N = 0;
}
else
N = (N << 3) + (N << 1) + ch - '0';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment