50分纠错

P1307 [NOIP2011 普及组] 数字反转

sumfer @ 2016-12-19 20:19:57

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
   int a,b=0;
   cin>>a;
   if(b<0)
   {
       a=-a;
       cout<<"-";
     }
   while(a>0) 
   {
       b=b*10+a%10;
       a/=10;
   } 
    cout<<b;
    return 0;
}

by WANGjerry @ 2017-01-15 09:44:21

读入就会爆


by xunzhen @ 2017-01-18 11:52:57

cin>>a下面应该是if(a<0)


|