fastinput c 2b 2b

Solutions on MaxInterview for fastinput c 2b 2b by the best coders in the world

showing results for - "fastinput c 2b 2b"
Louis
26 Aug 2018
1void fastInput(int &x)
2    {
3        bool neg=false;
4        register int c;
5        x =0;
6        c=getchar();
7        if(c=='-')
8        {
9            neg = true;
10            c=getchar();
11        }
12        for(;(c>47 && c<58);c=getchar())
13          	//bit shifting is faster than other operation
14          	//here code below is same as 
15          	//x = x*10 + c-48
16          
17            x = (x<<1) + (x<<3) +c -48;
18        if(neg)
19            x *=-1;
20    }