maybye better than cout/cin

Revision en3, by amsen, 2016-03-18 16:47:12

I see lots of problems about cout/cin , most of them are telling that cin/cout are slow and it's better to use scanf/printf;

but cin/cout are prettier and more easy to code for c++ coders. so i try to make an IO that it's pretty and fast.


#include <bits/stdc++.h> using namespace std; class FastIO{ public: //Output operators : inline FastIO & operator << (const int &a){ printf("%d" , a); return *this; } inline FastIO & operator << (const long long &a){ printf("%I64d" , a); return *this; } inline FastIO & operator << (const double &a){ printf("%.9f" , a); return *this; } inline FastIO & operator << (const long double &a){ printf("%.9lf" , a); return *this; } inline FastIO & operator << (const char * const&a){ printf("%s" , a); return *this; } inline FastIO & operator << (const string &a){ printf("%s" , a.c_str()); return *this; } //Input operators : inline FastIO & operator >> (int &a){ scanf("%d" , &a); return *this; } inline FastIO & operator >> (long long &a){ scanf("%I64d" , &a); return *this; } inline FastIO & operator >> (double &a){ scanf("%lf" , &a); return *this; } inline FastIO & operator >> (long double &a){ scanf("%lf" , &a); return *this; } inline FastIO & operator >> (char * const&a){ scanf("%s" , a); return *this; } }fastIO;//you can change it to cin/cout int main(){ int a;long long b;double c; fastIO >> a >> b >> c << a << " , " << b << " , " << c << "\n"; }
Tags fastio, iostream, c++

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English amsen 2016-03-18 16:48:01 1
en3 English amsen 2016-03-18 16:47:12 0 (published)
en2 English amsen 2016-03-18 16:46:45 3
en1 English amsen 2016-03-18 16:45:12 1538 Initial revision (saved to drafts)