8.01.2011

FAST-IO : fast input output (i/o) in c++ cpp for programming events

  1. /**************FAST-IO***************/
  2. void getnum( int &x)
  3. {
  4. x=0;
  5. char ch=getchar_unlocked();
  6. while( ch<'0' || ch>'9')
  7. ch=getchar_unlocked();
  8. while( ch>='0' && ch<='9')
  9. {
  10. x= 10*x+ ch-'0';
  11. ch=getchar_unlocked();
  12. }
  13. }
  14. void putnum( int x)
  15. {
  16. char s[30];
  17. int pi=-1;
  18. do{
  19. s[++pi]= (x-x/10*10)+'0';
  20. x/=10;
  21. }
  22. while( x>0);
  23. ++pi;
  24. while( pi)
  25. putchar_unlocked(s[--pi]);
  26. putchar_unlocked(' ');
  27. }
  28. /************************************/

No comments: