用char数组多方便
by Hope2075 @ 2018-09-16 11:09:49
@[2018陈子珺](/space/show?uid=113406)
大佬,这是我帮您重写了一遍的。。。
```cpp
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
int a;
cin >> a;//读入原数
int b = 0;
if(a < 0){//如果a是负数
a = abs(a);//先取一次绝对值
while(a){
b = b * 10 + a % 10;//反转
a /= 10;
}
cout << -b;//输出时把它变回负的
}
else{
while(a){
b = b * 10 + a % 10;
a /= 10;
}
cout << b;
}
return 0;
}
```
by 御坂19000号 @ 2018-09-16 11:21:25
@[御坂19000号](/space/show?uid=109181) 谢谢谢谢
by 2018陈子珺 @ 2018-09-16 11:28:23