我已經瞭解到使用getchar_unlocked
是快速讀取輸入的方式。我已經看到了許多地方的代碼閱讀,但無法理解。任何人都可以請幫我理解如何閱讀getchar_unlocked
? 在此先感謝。使用getchar_unlocked()讀取輸入()
void scanint(int &x)
{
register int c = getchar_unlocked();
x = 0;
for(;(c<48 || c>57);c = getchar_unlocked())
;
for(;c>47 && c<58;c = getchar_unlocked())
{
x = (x<<1) + (x<<3) + c - 48;
}
}
我也見過很多其他的代碼。我沒有特別明白轉移號碼的目的。任何有關的幫助表示讚賞
使用'(c&15)'而不是'c-48'可以更快。 –