编程语言
首页 > 编程语言> > c++快读快写

c++快读快写

作者:互联网

文章目录

快读

int read()  
{  
    int s = 0, f = 1;  
    char ch = getchar();  
    while(!isdigit(ch)) {  
        if(ch == '-') f = -1;  
        ch = getchar();  
    }  
    while(isdigit(ch)) {  
        s = s * 10 + ch - '0';  
        ch = getchar();  
    }  
    return s * f;  
}  

快写


void write(int x)  
{  
    if(x < 0) {  
        putchar('-');  
        x = -x;  
    }  
    if(x > 9)  
        write(x/10);  
    putchar(x % 10 - '0');  
    return;  
}  

标签:10,ch,int,c++,isdigit,快读,getchar
来源: https://blog.csdn.net/qi_programmer/article/details/122972691