跳到正文

个人记录

快读,快写模板C++

Wonderful_Anser约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月28日
更新
2025年12月28日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1

快读

C++
void read(int &a)
{
    a = 0;
    char c;
    while ((c = getchar()) < 48);
    do a = a * 10 + (c ^ 48);
    while ((c = getchar()) > 47);
}

快写

C++
void write(int x)
{
    static int sta[35];
    int top = 0;
    do
    {
        sta[top++] = x % 10;
        x /= 10;
    } while (x);
    while (top) putchar(sta[--top] + '0');
}
原文