-
-
Save zsrinivas/86d80b1a6193ff5426fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
template <class number> | |
void input(number *ptr){ | |
register char c = getchar_unlocked(); | |
while (c < 33) | |
c = getchar_unlocked(); | |
*ptr = 0; | |
while (c > 33){ | |
*ptr = (*ptr * 10) + (c - '0'); | |
c = getchar_unlocked(); | |
} | |
} | |
template <class number> | |
void print(number n, char end = '\n'){ | |
register char c; | |
char num[20]; | |
int i = 0; | |
do{ | |
num[i++] = n%10 + 48; | |
n /= 10; | |
} while (n != 0); | |
i--; | |
while (i >= 0) | |
putchar_unlocked(num[i--]); | |
putchar_unlocked(end); | |
} | |
template <class number> | |
void input(number *ptr){ | |
register char c = getchar_unlocked(); | |
bool sign = false; | |
while (c < 33) | |
c = getchar_unlocked(); | |
*ptr = 0; | |
if (c == '-'){ | |
sign = true; | |
c = getchar_unlocked(); | |
} | |
while (c > 33){ | |
*ptr = (*ptr * 10) + (c - '0'); | |
c = getchar_unlocked(); | |
} | |
if (sign) | |
*ptr *= -1; | |
} | |
template <class number> | |
void print(number n, char end = '\n'){ | |
register char c; | |
char num[20]; | |
int i = 0; | |
bool sign = false; | |
if (n < 0){ | |
sign = true; | |
n *= -1; | |
} | |
do{ | |
num[i++] = n%10 + 48; | |
n /= 10; | |
} while (n != 0); | |
i--; | |
if (sign) | |
putchar_unlocked('-'); | |
while (i >= 0) | |
putchar_unlocked(num[i--]); | |
putchar_unlocked(end); | |
} | |
void print(const char* format, ...){ | |
va_list arguments; | |
va_start(arguments, format); | |
register char c; | |
char num[20]; | |
int i = 0, j; | |
long n; | |
while (format[i] != '\0'){ | |
if (format[i] != '{') | |
putchar_unlocked(format[i++]); | |
else{ | |
i += 2; | |
n = va_arg(arguments, long); | |
j = 0; | |
do{ | |
num[j++] = n%10 + 48; | |
n /= 10; | |
} while (n != 0); | |
j--; | |
while (j >= 0) | |
putchar_unlocked(num[j--]); | |
} | |
} | |
va_end(arguments); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment