Created
February 25, 2017 04:48
-
-
Save mhtocs/25eb45f1ee5ff818492eaa2e4c5d6b0e to your computer and use it in GitHub Desktop.
Fast I/O in C/C++
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
/* | |
grab the whole line | |
char a[100]; | |
cin.getline(a,100); | |
scanf("%[^\n]",a); | |
gets(a); | |
*/ | |
inline void fastRead_int(int *a) | |
{ | |
register char c=0; | |
while (c<33) c=getchar_unlocked(); | |
*a=0; | |
while (c>33) | |
{ | |
*a=*a*10+c-'0'; | |
c=getchar_unlocked(); | |
} | |
} | |
inline void fastRead_string(char *str) | |
{ | |
register char c=0; | |
register int i = 0; | |
while (c < 33) | |
c = getchar_unlocked(); | |
while (c > 65) | |
{ | |
str[i] = c; | |
c = getchar_unlocked(); | |
i = i + 1; | |
} | |
str[i] = '\0'; | |
} | |
int main() | |
{ | |
int n; | |
char s[16]; | |
fastRead_int(&n); | |
fastRead_string(s); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment