题解 | #数字颠倒#

数字颠倒

http://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe

按照题目要求,输入是一个int型的变量,循环获取其最低位后转成字符加到字符串str中,最后输出str

#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

void fun(int n)
{
    string str;
    while(n)
    {
        str += (n%10)+'0';
        n /= 10;
    }

    cout << str << endl;
}

int main()
{
    int n;
    while(scanf("%d", &n) != EOF)
    {
        fun(n);
    }
    return 0;
}
全部评论

相关推荐

asdasdasda...:19岁,不容易啊可能升个本会好点,现在学历歧视太严重了
点赞 评论 收藏
分享
程序员牛肉:这一眼假啊,基本上都是骗人的,不然就涉及到职位贪腐了,就像之前华为的OD事件,看你运气好不好了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务