码迷,mamicode.com
首页 > 其他好文 > 详细

A+B Problem(V)

时间:2014-11-04 00:08:16      阅读:300      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   os   for   sp   strong   数据   

A+B Problem(V)

描述

做了A+B Problem之后,Yougth感觉太简单了,于是他想让你求出两个数反转后相加的值。帮帮他吧

 
输入
有多组测试数据。每组包括两个数m和n,数据保证int范围,当m和n同时为0是表示输入结束。
输出
输出反转后相加的结果。
样例输入
1234 1234
125 117
0 0
样例输出
8642
1232

 
#include <iostream>
#include <cmath>
using namespace std;

int rever(int n)
{
    int s=0;
    int ss[1000]={0};
    while(n)
    {
        ss[s++]=n%10;
        n/=10;
    }
    int sum=0;
    for(int i=0;i<s;i++)
        sum += ss[i]*(pow(10,(s-i-1)));

    return sum;
}

int main()
{
    int a,b;
    while(cin>>a>>b && !(a==0 && b==0))
    {
        int re=rever(a)+rever(b);
        cout<<re<<endl;
    }
    return 0;
}        

 

A+B Problem(V)

标签:style   blog   io   color   os   for   sp   strong   数据   

原文地址:http://www.cnblogs.com/imwtr/p/4072472.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!