欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

输入输出外挂

程序员文章站 2024-03-17 16:22:16
...

板子不解释

//适用于正负整数
template <class T>
inline bool scan_d(T &ret)
{
    char c; int sgn;
    if(c=getchar(),c==EOF) return 0; //EOF
    while(c!='−'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='−')?−1:1;
    ret=(c=='−')?0:(c−'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c−'0');
    ret*=sgn;
    return 1;
}
inline void out(int x)
{
    if(x>9) out(x/10);
    putchar(x%10+'0');
}
//正负数
template <class T>
bool scan_d(T &ret)
{
    char c; 
    int sgn; 
    T bit = 0.1;
    if (c=getchar(), c==EOF) 
    {
        return 0;
    }
    while (c! = '-' && c != '.' && (c < '0' || c > '9')) 
    {
        c = getchar();
    }
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9')
    {
        ret = ret * 10 + (c - '0');
    }
    if (c == ' ' || c == '\n')
    {
        ret *= sgn;
        return 1;
    }
    while (c = getchar(), c >= '0' && c <= '9')
    {
        ret += (c - '0') * bit, bit /= 10;
    }
    ret *= sgn;
    return 1;
}

template <class T>
inline void print_d(int x)
{
    if (x > 9)
    {
        print_d(x / 10);
    }
    putchar(x % 10 + '0');
}