读入读出挂

Posted redblackk

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了读入读出挂相关的知识,希望对你有一定的参考价值。

正数

 1 void re(int &x)
 2 {
 3     x=0;char s=getchar();
 4     while(s<0||s>9) s=getchar();
 5     while(s>=0&&s<=9){x=x*10+s-0;s=getchar();}
 6 }
 7 void wr(int x)
 8 {
 9     if(x>9) wr(x/10);
10     putchar(x%10+0);
11 }

正负

 1 void re(int &x)
 2 {
 3     int f=1;x=0;char s=getchar();
 4     while(s<0||s>9){if(s==-)f=-1;s=getchar();}
 5     while(s>=0&&s<=9){x=x*10+s-0;s=getchar();}
 6     x*=f;
 7 }
 8 void wr(int x)
 9 {
10     if(x<0){putchar-; x=-x;}
11     if(x>9)wr(x/10);
12     putchar(x%10+0);
13 }

 

完。

以上是关于读入读出挂的主要内容,如果未能解决你的问题,请参考以下文章