版本比较
【模板】快读快写
正文
增加 29 行删除 4 行
1123456789101112131415161718192021222324252627282930313233343536373839404119424344454625 行未改动7273747553767778798037 行未改动11811912012199122123124125126# 压行精简版```cpp#ifndef _QUICK_IO#define _QUICK_IOstruct qistream{}qin;struct qostream{}qout;template<typename T>inline T readint(){short __f=1;T __num=0;char __c=getchar();while(!isdigit(__c)&&__c!='-')__c=getchar();if(__c=='-')__f=-1,__c=getchar();while(isdigit(__c))__num=__num*10+__c-'0',__c=getchar();return __num*__f;}template<typename T>qistream&operator>>(qistream&in,T&__a){return __a=readint<T>(),in;}qistream&operator>>(qistream&in,char&__a){__a=getchar();while(__a==' '||__a=='\n')__a=getchar();return in;}qistream&operator>>(qistream&in,char*__a){char __c=getchar();while(__c==' '||__c=='\n')__c=getchar();while(__c!=' '&&__c!='\n')*__a++=__c,__c=getchar();*__a='\0';return in;}qistream&operator>>(qistream&in,std::string&__a){__a.clear();char __c=getchar();while(__c==' '||__c=='\n')__c=getchar();while(__c!=' '&&__c!='\n')__a.push_back(__c),__c=getchar();return in;}template<typename T>void __write(T __a){if (!__a)return;__write(__a/10);putchar(__a%10+'0');}template<typename T>qostream&operator<<(qostream&out,T __a){if (__a<0)putchar('-'),__a=-__a;if (!__a)putchar('0');else __write(__a);return out;}qostream&operator<<(qostream&out,char __a){putchar(__a);return out;}qostream&operator<<(qostream&out,char*__s){while(*__s)putchar(*__s++);return out;}qostream&operator<<(qostream&out,const char*__s){while(*__s)putchar(*__s++);return out;}qostream&operator<<(qostream&out,const std::string&__s){out<<__s.c_str();return out;}#define cin qin#define cout qout#define endl '\n'#endif```
:::info[历史版本]
### 压行精简版```cpp#ifndef _QUICK_IO#define _QUICK_IOstruct qistream{}qin;struct qostream{}qout;template<typename T>inline T readint(){short __f=1;T __num=0;char __c=getchar();while(!isdigit(__c)&&__c!='-')__c=getchar();if(__c=='-')__f=-1,__c=getchar();while(isdigit(__c))__num=__num*10+__c-'0',__c=getchar();return __num*__f;}template<typename T>qistream&operator>>(qistream&in,T&__a){return __a=readint<T>(),in;}qistream&operator>>(qistream&in,char&__a){__a=getchar();while(__a==' '||__a=='\n')__a=getchar();return in;}template<typename T>void __write(T __a){if (!__a)return;__write(__a/10);putchar(__a%10+'0');}template<typename T>qostream&operator<<(qostream&out,T __a){if (__a<0)putchar('-'),__a=-__a;if (!__a)putchar('0');else __write(__a);return out;}qostream& operator<<(qostream& out,char __a){putchar(__a);return out;}qostream& operator<<(qostream& out,const char* __s){while(*__s)putchar(*__s++);return out;}#define cin qin#define cout qout#define endl '\n'#endif```
# 手写原生版### 手写原生版```cpp#ifndef _QUICK_IO#define _QUICK_IOstruct qistream{} qin;25 行未改动 return out;}#endif```# 模板精装版### 模板精装版```cpp#ifndef _QUICK_IO#define _QUICK_IOstruct qistream {} qin;37 行未改动#define cout qout#define endl '\n'#endif```# :::
---卡常专用:`#define getchar() getchar_unlocked()`