文章

6

粉丝

312

获赞

3

访问

63.9k

头像
数字反转
P1276 上海交通大学机试题
发布于2020年3月9日 08:54
阅读数 9.7k


#include <iostream>
using namespace std;
int reverse(int n)
{
    int res=0;
    while(n>0)
        {
            res=n%10+res*10;
            n /=10;
        }
    return res;
    

int main()
{
    int x,y;
    while(cin>>x>>y)
    {
    
        int res1;
        res1=reverse(x)+reverse(y);
        if(res1==reverse(x+y)) 
        {
            cout<<x+y<<endl;
        }
        else
        &n...

登录查看完整内容


登录后发布评论

1 条评论
admin SVIP
2020年3月9日 08:57

建议用代码插件,高亮语法显示,更容易阅读wink

赞(0)