题解 | #数字颠倒#

数字颠倒

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;
全部评论

相关推荐

投递美团等公司10个岗位
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务