快读快写模板

  • 快读
#include<iostream>
#include<cstdio>
using namespace std; 
inline long long read()
{
    long long s = 0,f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')
        {
            f = -f;
        }
        ch=getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        s = s * 10 + (ch ^ 48);
        ch = getchar();
    }
    return s * f;
}
int main()
{
    int x=read();
    cout<<x;
    return 0; 
}
  • 快写
#include<iostream>
using namespace std;
inline void write(long long x)
{
    if(x<0)
    {
        putchar('-');
        x = -x;
    }
    if(x>9)
    {
        write(x / 10);
    }
    putchar(x % 10 + '0');
}
int main()
{
    int n;
    cin>>n;
    write(n);
    return 0;
}

0 条评论

目前还没有评论...