题解 | #数字颠倒#
数字颠倒
http://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
采用字符串拼接和类型转化的方式进行
unsigned int x,t;
int y = 1;
string str;
cin >> x;
t = x;
while (t / 10)
{
t /= 10;
y++;
}
for (int i = 0; i < y; i++)
{
int z = x % 10;
x /= 10;
char c = char('0' + z);
str += c;
}
cout << str;