主页
搜索
最近更新
数据统计
申请密钥
系统公告
1
/
1
请查看完所有公告
重载cin&cout(自动快读机)V2.0
最后更新于 2025-07-31 09:42:59
作者
违规用户名1451514
分类
科技·工程
复制 Markdown
查看原文
删除文章
更新内容
### $重载cin\&cout(自动快读机)\textcolor{red}{\Large{V}\normalsize{2.0}}$ ```cpp /* 重载cin&cout(自动快读机) */ #include<stdio.h> #include<type_traits> #include<algorithm> #include<array> #include<atomic> #include<bitset> #include<cassert> #include<ccomplex> #include<cctype> #include<cerrno> #include<cfenv> #include<cfloat> #include<chrono> #include<cinttypes> #include<ciso646> #include<climits> #include<clocale> #include<cmath> #include<complex> #include<complex.h> #include<condition_variable> #include<csetjmp> #include<csignal> #include<cstdalign> #include<cstdarg> #include<cstdbool> #include<cstddef> #include<cstdint> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctgmath> #include<ctime> #include<cwchar> #include<cwctype> #include<cxxabi.h> #include<deque> #include<exception> #include<fenv.h> #include<forward_list> #include<fstream> #include<functional> #include<future> #include<initializer_list> #include<iomanip> #include<ios> #include<iosfwd> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<mutex> #include<new> #include<numeric> #define slp Sleep #define pc putchar using namespace std; inline int read_int(){int res = 0;char c=getchar();bool q=0;while(c<'0'||c>'9'){if(c=='-')q=1;c=getchar();}res=(c^48);while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+(c^48);if(q)res=-res;return res;} inline double read_double(){double x = 0, y = 1.0;int f = 0, dec = 0;char ch = getchar();while (ch < '0' || ch > '9') {if (ch == '-') f = 1;ch = getchar();}while ((ch >= '0' && ch <= '9') || ch == '.') {if (ch == '.') dec = 1;else if (!dec) x = x * 10 + (ch - '0');else x += (y /= 10) * (ch - '0');ch = getchar();}return f ? -x : x;} inline char read_char(){char res;while((res = getchar()) != EOF && isspace(res));return res;} inline char* read_chars(){char* s;int sum=0;char ch = getchar();while (isspace(ch)) ch = getchar();while (!isspace(ch) && ch != EOF) {s[++sum]=ch;ch = getchar();}return s;} inline string read_string(){string s;char ch = getchar();while (isspace(ch)) ch = getchar();while (!isspace(ch) && ch != EOF) {s.push_back(ch);ch = getchar();}return s;} inline void write_int(auto x){if(x < 0)putchar('-'), x = -x;if(x > 9)write_int(x / 10);putchar(x % 10 + '0');} inline void write_chars(const char* s){while(*s)fputc(*s++, stdout);} void write_double(double x, int precision = 6){if (x < 0) {putchar('-');x = -x;}x += 5 * pow(10, -precision - 1);long long integer = (long long)x;double decimal = x - integer;if (integer == 0) {putchar('0');} else {char buffer[20];int pos = 0;while (integer > 0) {buffer[pos++] = '0' + integer % 10;integer /= 10;}while (--pos >= 0) putchar(buffer[pos]);}if (precision > 0) {putchar('.');while (precision--) {decimal *= 10;int digit = (int)decimal;putchar('0' + digit);decimal -= digit;}}} #define forr(l, r) for(int i = l; i <= r; i++) void cin_list(int l, int r, int *a){for(int i = l; i <= r; i++)a[i]=read_int();} void cout_list(int l, int r, int *a, char sep=' ', char end='\n'){for(int i = l; i <= r; i++)write_int(a[i]),putchar(sep);putchar(end);} void Merge_Sort(int l, int r, int *a, int *t){if(l>=r)return;int mid=(l+r)/2;Merge_Sort(l, mid, a, t);Merge_Sort(mid+1, r, a, t);int i=l, j=mid+1, s=l;while(i<=mid&&j<=r){if(a[i]<=a[j])t[s++]=a[i++];else t[s++]=a[j++];}while(i<=mid)t[s++]=a[i++];while(j<=r)t[s++]=a[j++];for(int i = l; i <= r; i++)a[i]=t[i];} void qsort(int l, int r, int *a){int x = a[(l + r) / 2];int i = l, j = r;while(i <= j){while(a[i] < x)i++;while(a[j] > x)j--;if(i <= j){swap(a[i], a[j]);i++;j--;}}if(l < j)qsort(l, j, a);if(i < r)qsort(i, r, a);} #define pc putchar #define gcd(x, y) __gcd(x, y); #define lcm(x, y) __lcm(x, y); struct inout{ //1.(>>)部分 inout& operator>>(int& res){ res=read_int(); return *this; } inout& operator>>(unsigned int& res){ res=read_int(); return *this; } inout& operator>>(unsigned long& res){ res=read_int(); return *this; } inout& operator>>(long long& res){ res=read_int(); return *this; } inout& operator>>(unsigned long long& res){ res=read_int(); return *this; } inout& operator>>(float& res){ res=read_double(); return *this; } inout& operator>>(double& res){ res=read_double(); return *this; } inout& operator>>(long double& res){ res=read_double(); return *this; } inout& operator>>(char& res){ res = getchar(); return *this; } inout& operator>>(string& res){ res = read_string(); return *this; } //2.(<<)部分 inout& operator<<(const int& res){ write_int(res); return *this; } inout& operator<<(const unsigned int& res){ write_int(res); return *this; } inout& operator<<(const unsigned long& res){ write_int(res); return *this; } inout& operator<<(const long long& res){ write_int(res); return *this; } inout& operator<<(const unsigned long long& res){ write_int(res); return *this; } inout& operator<<(const float& res){ write_double(res); //注:默认六位 return *this; } inout& operator<<(const double& res){ write_double(res); //注:默认六位 return *this; } inout& operator<<(const long double& res){ write_double(res, 10); //注:默认十位 return *this; } inout& operator<<(const char& res){ putchar(res); return *this; } inout& operator<<(const string& res){ write_chars(res.c_str()); return *this; } }cin, cout;
正在渲染内容...
点赞
1
收藏
1