Last active
February 25, 2017 05:18
-
-
Save mhtocs/b1870fa45b3eaa7ec224d43a89710040 to your computer and use it in GitHub Desktop.
Fast I/O in cpp (for Enormous Dataset on spoj)
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
#include <bits/stdc++.h> | |
using namespace std; | |
#define usingcincout ios::sync_with_stdio(0);cin.tie(0); | |
template <class T> | |
void getInt(T& n) { | |
n = 0; | |
int sign=1; | |
register char c=0; | |
while(c<33) | |
c=getchar_unlocked(); | |
if (c=='-'){ | |
sign=-1; | |
c=getchar_unlocked(); | |
} | |
while(c>='0'&&c<='9'){ | |
n=(n<<3)+(n<<1)+(c-'0'); | |
c=getchar_unlocked(); | |
} n *= sign; | |
} | |
template <class T> | |
void printInt(T a) { | |
char num[20]; | |
int i = 0; | |
if(a < 0) { | |
putchar_unlocked('-'); | |
a *= -1; | |
} | |
do { | |
num[i++] = a%10 + 48; | |
a /= 10; | |
} while (a != 0); | |
i--; | |
while (i >= 0) | |
putchar_unlocked(num[i--]); | |
} | |
inline void ReadStr(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'; | |
} | |
inline void printString(char* s) | |
{ | |
while(*s) | |
putchar_unlocked(*(s++)); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
int32_t t; | |
printString("Enter a number"); | |
getInt(t); | |
printInt(t); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment