Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #define pc(x) putchar_unlocked(x);
  2. inline void writeInt (int n)
  3. {
  4. int N = n, rev, count = 0;
  5. rev = N;
  6. if (N == 0) {
  7. pc('0');
  8. pc('n');
  9. return;
  10. }
  11. while ((rev % 10) == 0) {
  12. count++;
  13. rev /= 10;
  14. //obtain the count of the number of 0s
  15. }
  16. rev = 0;
  17. while (N != 0) {
  18. rev = (rev<<3) + (rev<<1) + N % 10;
  19. N /= 10;
  20. //store reverse of N in rev
  21. }
  22. while (rev != 0) {
  23. pc(rev % 10 + '0');
  24. rev /= 10;
  25. }
  26. while (count--) pc('0');
  27. pc('n'); //this line prints new line and the reason for 1 second delay!
  28. }
  29.  
  30. setvbuf(stdout, NULL, _IOFBF, 0);
  31.  
  32. fflush(stdout);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement