fread write 求调
  • 板块学术版
  • 楼主卷王慢即快
  • 当前回复6
  • 已保存回复8
  • 发布时间2024/3/1 16:31
  • 上次更新2024/3/1 20:08:19
查看原帖
fread write 求调
494699
卷王慢即快楼主2024/3/1 16:31

为什么我的 fread write 输出不了啊。文件输入输出也不行。三种形式的 write 都输出不了。

char buf[1 << 12], obuf[1 << 12], *p1 = buf, *p2 = buf, *p3 = obuf, sr[1 << 23], z[23], nc;
int C = -1, Z = 0, Bi = 0;
#define gc() p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 12, stdin), p1 == p2) ? EOF : *p1++
#define pc(ch) (p3 - obuf < 1000000) ? (*p3 ++ = ch) : (fwrite(obuf, p3 - obuf, 1, stdout), p3 = obuf, *p3 ++ = ch)
inline long long read() {
	long long x = 0, y = 1;
	while (nc = gc(), (nc < 48 || nc > 57) && nc != -1)if (nc == 45)y = -1;
	Bi = 1;
	x = nc - 48;
	while (nc = gc(), 47 < nc && nc < 58)x = (x << 3) + (x << 1) + (nc ^ 48), Bi++;
	return x * y;
}
inline double gf() {
	int a = read(), b = (nc != '.') ? 0 : read();
	return (b ? a + (double)b / pow(10, Bi) : a);
}
inline int gs(char *s) {
	char c, *t = s;
	while (c = gc(), c < 32);
	*s++ = c;
	while (c = gc(), c > 32) * s++ = c;
	return s - t;
}
template <typename T>
inline void write(T x, char t) {
	if (x < 0) x = -x, pc('-');
	while (x) z[Z++] = x % 10 + '0', x /= 10;
	z[Z++] = t;
	while (Z--) pc(z[Z]);
}
inline void write(long long x) {
	if (x < 0) x = -x, pc('-');
	while (x) z[Z++] = x % 10 + '0', x /= 10;
	while (Z--) pc(z[Z]);
}
inline void write(char *s) {
	int l = strlen(s);
	for (int i = 0; i < l; i++) sr[C++] = *s++;
	sr[C++] = '\n';
	while (C--) pc(sr[C]);
}
2024/3/1 16:31
加载中...