首页 > 其他 > 详细

P1307 数字反转

时间:2019-07-26 21:56:49      阅读:116      评论:0      收藏:0      [点我收藏+]

P1307 数字反转

题目链接:https://www.luogu.org/problem/P1307

代码

#include <bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    long long n,a,b=0;
    cin>>n;
    while(n%10==0){    //判断n后几位有零的情况;
        n = n/10;
        //cout<<n<<endl;
    }
    while(n!=0){
        a = n%10;
        b = b*10+a;    //把除去尾数为零的n从后往前存入b中;
        n = n/10;
        //cout<<a<<""<<b<<" "<<n<<" ";
    }
    cout<<b<<endl;
    return 0;
}

P1307 数字反转

原文:https://www.cnblogs.com/zz9100/p/11252984.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!