What is input hanging?
It is well known that scanf is much faster than CIN, so is there anything faster than scanf? The answer is that the input is hung, the input is used to tell the Read function GetChar (), and then manually processed into an integer or floating point, much faster than using scanf.
When do I use input to hang up?
When the input scale reaches 1x10^6, it is necessary to enter the hanging, otherwise it is likely to time out.
Code
The code is not written by me, here is the source: http://www.cnblogs.com/xiaohongmao/archive/2012/05/29/2523760.html
Integer
InlineBOOLScan_d (int&num) { Char inch;BOOLisn=false; inch=GetChar (); if(inch==eof)return false; while(inch!='-'&& (inch<'0'||inch>'9'))inch=GetChar (); if(inch=='-') {isn=true; num=0;} Elsenum=inch-'0'; while(inch=getchar (),inch>='0'&&inch<='9') {num*=Ten, num+=inch-'0'; } if(IsN) num=-num; return true;}
Floating point
InlineBOOLSCAN_LF (Double&num) { Char inch;DoubleDec=0.1; BOOLisn=false, isd=false; inch=GetChar (); if(inch==eof)return false; while(inch!='-'&&inch!='.'&& (inch<'0'||inch>'9')) inch=GetChar (); if(inch=='-') {isn=true; num=0;} Else if(inch=='.') {isd=true; num=0;} Elsenum=inch-'0'; if(!IsD) { while(inch=getchar (),inch>='0'&&inch<='9') {num*=Ten; num+=inch-'0';} } if(inch!='.'){ if(IsN) num=-num; return true; }Else{ while(inch=getchar (),inch>='0'&&inch<='9') {num+=dec* (inch-'0');D ec*=0.1; } } if(IsN) num=-num; return true;}
ACM Principles _ Input Hang