SHARE
TWEET

Untitled

a guest Aug 24th, 2015 359 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdio>
  2.  
  3. class InputReader {
  4.     public:
  5.         InputReader() {}
  6.         InputReader(const char *file_name) {
  7.             input_file = fopen(file_name, "r");
  8.             cursor = 0;
  9.             fread(buffer, SIZE, 1, input_file);
  10.         }
  11.         inline InputReader &operator >>(int &n) {
  12.             while(buffer[cursor] < '0' || buffer[cursor] > '9') {
  13.                 advance();
  14.             }
  15.             n = 0;
  16.             while('0' <= buffer[cursor] && buffer[cursor] <= '9') {
  17.                 n = n * 10 + buffer[cursor] - '0';
  18.                 advance();
  19.             }
  20.             return *this;
  21.         }
  22.     private:
  23.         FILE *input_file;
  24.         static const int SIZE = 1 << 17;
  25.         int cursor;
  26.         char buffer[SIZE];
  27.         inline void advance() {
  28.             ++ cursor;
  29.             if(cursor == SIZE) {
  30.                 cursor = 0;
  31.                 fread(buffer, SIZE, 1, input_file);
  32.             }
  33.         }
  34. };
  35.  
  36. int main () {
  37.         InputReader cin("fisier.in");
  38.        
  39.         //Se foloseste exact ca std :: cin
  40.         int var;
  41.         cin >> var;
  42.  
  43.         return 0;
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top