1.0
快读快输,不支持连读连输,但读入后可以直接按使用。
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n, a, ans;
namespace wpl{
//#define getchar getchar_unlocked
void in(int &x){
x = 0;
int f = 1;
char ch = getchar();
while(ch < '0' || ch > '9'){
if(ch == '-') f *= -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
x *= f;
}
void inl(long long &x){
x = 0;
int f = 1;
char ch = getchar();
while(ch < '0' || ch > '9'){
if(ch == '-') f *= -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
x *= f;
}
void out(long long x){
if(!x) return ;
out(x / 10), putchar(x % 10 + '0');
}
struct OUT{
void operator << (const long long &bd){
long long f = 1;
if(bd < 0) putchar('-'), f = -1;
out(f * bd);
}
}_cout;
struct IN{
void operator >> (int &bd){
in(bd);
}
}_cin;
struct INl{
void operator >> (long long &bd){
inl(bd);
}
}_cinl;
}using namespace wpl;
int main(){
_cin >> n;
for(int i = 1; i <= n; i++) _cin >> a, ans += a;
_cout << ans;
return 0;
}2.0
支持连读,但输出要求更高,读入后需 时间转换才能取出正真可以运算的数值,<< 数值后面跟一个空格,|| 数值后面跟一个换行,可以在源码处更改。
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
namespace wpl{
//#define getchar getchar_unlocked
void in(int &x){
x = 0;
int f = 1;
char ch = getchar();
while(ch < '0' || ch > '9'){
if(ch == '-') f *= -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
x *= f;
}
void out(int x){
if(!x) return ;
out(x / 10), putchar(x % 10 + '0');
}
struct IN{
int d;
IN operator >> (IN &bd){
in(bd.d);
return bd;
}
IN operator << (const IN &bd){
int f = 1;
if(bd.d < 0) putchar('-'), f = -1;
out(f * bd.d), putchar(' ');
return bd;
}
IN operator || (const IN &bd){
int f = 1;
if(bd.d < 0) putchar('-'), f = -1;
out(f * bd.d), putchar('\n');
return bd;
}
}_cin, _cout;
}using namespace wpl;
int main(){
IN A, B, C, D;
_cin >> A >> B >> C >> D;
//out(A.d), putchar(' '), out(B.d), putchar(' '), out(C.d), putchar(' '), out(D.d);
_cout << A << B << C || D;
return 0;
}