Sun Moon
4
Q:

fastinput c++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    return 0;
}
2
    ios_base::sync_with_stdio(false);
0
void fastscan(int &number) 
{ 
    //variable to indicate sign of input number 
    bool negative = false; 
    register int c; 
  
    number = 0; 
  
    // extract current character from buffer 
    c = getchar(); 
    if (c=='-') 
    { 
        // number is negative 
        negative = true; 
  
        // extract the next character from the buffer 
        c = getchar(); 
    } 
  
    // Keep on extracting characters if they are integers 
    // i.e ASCII Value lies from '0'(48) to '9' (57) 
    for (; (c>47 && c<58); c=getchar()) 
        number = number *10 + c - 48; 
  
    // if scanned input has a negative sign, negate the 
    // value of the input number 
    if (negative) 
        number *= -1; 
} 
  
// Function Call 
int main() 
{ 
    int number; 
    fastscan(number); 
    cout << number << "\n"; 
    return 0; 
} 
0
void fastInput(int &x)
    {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
          	//bit shifting is faster than other operation
          	//here code below is same as 
          	//x = x*10 + c-48
          
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }
0

New to Communities?

Join the community