Hippskill

Untitled

Jan 28th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. #include <cstdio>
  2.  
  3. /***
  4.  * Unsigned
  5.  */
  6.  
  7. inline unsigned long long readULong()
  8. {
  9.   int c = getc(stdin);
  10.   unsigned long long x = 0;
  11.   while (c <= 32)
  12.     c = getc(stdin);
  13.   while ('0' <= c && c <= '9')
  14.     x = x * 10 + c - '0', c = getc(stdin);
  15.   return x;
  16. }
  17.  
  18. inline unsigned int readUInt()
  19. {
  20.   int c = getc(stdin);
  21.   unsigned int x = 0;
  22.   while (c <= 32)
  23.     c = getc(stdin);
  24.   while ('0' <= c && c <= '9')
  25.     x = x * 10 + c - '0', c = getc(stdin);
  26.   return x;
  27. }
  28.  
  29. inline void writeULong( unsigned long long x )
  30. {
  31.   char s[30];
  32.   int n = 0;
  33.   while (x || !n)
  34.     s[n++] = '0' + x % 10, x /= 10;
  35.   while (n--)
  36.     putc(s[n], stdout);
  37. }
  38.  
  39. inline void writeUInt( unsigned int x )
  40. {
  41.   char s[15];
  42.   int n = 0;
  43.   while (x || !n)
  44.     s[n++] = '0' + x % 10, x /= 10;
  45.   while (n--)
  46.     putc(s[n], stdout);
  47. }
  48.  
  49. /***
  50.  * Signed
  51.  */
  52.  
  53. inline int readInt()
  54. {
  55.   int s = 1, x = 0, c = getc(stdin);
  56.   while (c <= 32)
  57.     c = getc(stdin);
  58.   if (c == '-')
  59.     s = -1, c = getc(stdin);
  60.   while ('0' <= c && c <= '9')
  61.     x = x * 10 + c - '0', c = getc(stdin);
  62.   return x * s;
  63. }
  64.  
  65. inline void writeInt( int x )
  66. {
  67.   if (x < 0)
  68.     putc('-', stdout), x = -x;
  69.  
  70.   char s[20];
  71.   int n = 0;
  72.   while (x || !n)
  73.     s[n++] = '0' + x % 10, x /= 10;
  74.   while (n--)
  75.     putc(s[n], stdout);
  76. }
  77.  
  78. /***
  79.  * Word
  80.  */
  81.  
  82. inline void readWord( char *s )
  83. {
  84.   int c = getc(stdin);
  85.   while (c <= 32)
  86.     c = getc(stdin);
  87.   while (c > 32)
  88.     *s++ = c, c = getc(stdin);
  89.   *s = 0;
  90. }
  91.  
  92. inline void writeWord( char *s )
  93. {
  94.   while (*s)
  95.     putchar(*s++);
  96. }
Add Comment
Please, Sign In to add comment