plz help in understanding working of fast input/output method in C++ ......

Revision en2, by Dee_code, 2018-09-30 20:33:29

include <bits/stdc++.h>

template void scan(T &x) { x = 0; bool neg = 0; register T c = getchar();

if (c == '-') 
    neg = 1, c = getchar(); 

while ((c < 48) || (c > 57)) 
    c = getchar(); 

for ( ; c < 48||c > 57 ; c = getchar()); 

for ( ; c > 47 && c < 58; c = getchar() ) 
    x= (x << 3) + ( x << 1 ) + ( c & 15 ); 

if (neg) x *= -1;

}

template void print(T n) { bool neg = 0;

if (n < 0) 
    n *= -1, neg = 1; 

char snum[65]; 
int i = 0; 
do
{ 
    snum[i++] = n % 10 + '0'; 
    n /= 10; 
} 

while (n); 
--i; 

if (neg) 
    putchar('-'); 

while (i >= 0) 
    putchar(snum[i--]); 

putchar('\n');

}

// Driver Program int main() { int value;

// Taking input 
scan(value); 

// Printing output 
print(value); 
return 0;

}

Tags fast input/output

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Dee_code 2018-09-30 20:33:29 42
en1 English Dee_code 2018-09-30 20:31:52 1076 Initial revision (published)