OJ-Problems-Source/.ACM-Templates/TXTs/输入输出.txt

72 lines
2.2 KiB
Plaintext
Raw Normal View History

2016-11-22 09:38:35 +08:00
//<2F>ر<EFBFBD>ͬ<EFBFBD><CDAC>
ios_base::sync_with_stdio(false); cin.tie(NULL);
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD><EFBFBD>
template<typename T> void read(T &x) {
char c;
while (!isdigit(c = getchar()));
for (x = 0; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; }
}
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
template<typename T> void read(T &x) {
char c; bool neg = false;
while ((c = getchar()) != '-' && !isdigit(c));
if (c == '-') { neg = true; c = getchar(); }
for (x = 0; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; }
if (neg) { x = -x; }
}
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>(int, long long, float, double)
template<typename T> void read(T &x) {
char c; bool neg = false;
while ((c = getchar()) != '-' && c != '.' && !isdigit(c));
if (c == '-') { neg = true; c = getchar(); }
for (x = 0; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; }
if (c == ' ' || c == '\n' || c == EOF) { if (neg) { x = -x; } return; }
for (T bit = 0.1; isdigit(c = getchar()); bit *= 0.1) { x += (c - '0') * bit; }
if (neg) { x = -x; }
}
//<2F>ո<EFBFBD><D5B8><EFBFBD>Ϊ<EFBFBD>ָ<EFBFBD> <20><>ȡһ<C8A1>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
const int BUFSIZE = 1 << 20;
char BUF[BUFSIZE];
void readln(int a[]) {
int i = 0; gets(BUF);
for (char *p = strtok(BUF, " "); p; p = strtok(NULL, " ")) { sscanf(p, "%d", &a[i++]); }
}
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
template<typename T> void printn(T x) {
if (x > 9) { printn(x / 10); }
putchar(x % 10 + '0');
}
//<2F><><EFBFBD><EFBFBD>fread
const int BUFSIZE = 1 << 20;
char BUF[BUFSIZE + 1], *S, *T; bool eof;
inline char gc() {
if (S == T) {
S = BUF; T = BUF + fread(BUF, 1, BUFSIZE, stdin);
if (S == T) { eof = true; return EOF; }
}
return *S++;
}
template<typename T> void ni(T &x) {
char c; bool neg = false; x = 0;
while ((c = gc()) != '-' && !isdigit(c));
if (eof) { return; }
if (c == '-') { neg = true; c = gc(); }
for (; isdigit(c); c = gc()) { x = x * 10 + c - '0'; }
if (neg) { x = -x; }
}
void nd(double &x) {
char c; bool neg = false; x = 0;
while ((c = gc()) != '-' && !isdigit(c));
if (eof) { return; }
if (c == '-') { neg = true; c = gc(); }
for (; isdigit(c); c = gc()) { x = x * 10 + c - '0'; }
if (c == '.') { for (double bit = 0.1; isdigit(c = gc()); bit *= 0.1) { x += (c - '0') * bit; } }
if (neg) { x = -x; }
}
void ns(char *s) {
char c;
while (isspace(c = gc()));
if (eof) { return; }
for (; !isspace(c); c = gc()) { *s++ = c; } *s = 0;
}