A+B Problem(V)

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;
}        

时间: 2024-11-08 19:24:29

A+B Problem(V)的相关文章

南阳844--A+B Problem(V)

A+B Problem(V) 时间限制:1000 ms  |  内存限制:65535 KB 难度:1 描述 做了A+B Problem之后,Yougth感觉太简单了,于是他想让你求出两个数反转后相加的值.帮帮他吧 输入 有多组测试数据.每组包括两个数m和n,数据保证int范围,当m和n同时为0是表示输入结束. 输出 输出反转后相加的结果. 样例输入 1234 1234 125 117 0 0 样例输出 8642 1232 来源 Yougth原创 1 #include<stdio.h> 2 #i

A+B Problem(V) 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 做了A+B Problem之后,Yougth感觉太简单了,于是他想让你求出两个数反

#include<stdio.h> int main() { int i,j,a,b,n,m; while(1) { scanf("%d%d",&m,&n); if(m==0 && n==0) { break; } i=0; while(m!=0) { a=m%10; i=i*10+a; m=(m-a)/10; } j=0; while(n!=0) { b=n%10; j=j*10+b; n=(n-b)/10; } printf("

hdu 4974 A simple water problem(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4974 Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or

hdu 5349 MZL&#39;s simple problem(multiset)

代码: #include<set> #include<cstdio> using namespace std; multiset<int> st; int main() { int n; multiset<int>::iterator it; while(scanf("%d",&n)==1) { st.clear(); int k,num; for(int i=0; i<n; i++) { scanf("%d&qu

HDU - 4971 A simple brute force problem. (DP)

Problem Description There's a company with several projects to be done. Finish a project will get you profits. However, there are some technical problems for some specific projects. To solve the problem, the manager will train his employee which may

hdu 1016 Prime Ring Problem (dfs)

一切见注释. #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> using namespace std; bool vis[22]; int n; int ans[22]; int top; bool isprime(int x)//判断素数 { for(int i=2;i<x;i++) if(x%i==0)return false; return

uva10026 - Shoemaker&#39;s Problem(贪心)

题目:10026 - Shoemaker's Problem 题目大意:有个鞋匠在同一天接到了一堆的生意.可是他每天只能做一双鞋,给出做每双鞋需要的时间和推辞做鞋的赔偿.问怎样合理的分配才能使得赔偿最小. 解题思路:鞋子编号  要花的时间  需要的赔偿(每天) 1                    1                100 2                    5                  4 这样的两双鞋有两种安排: 做完1再做2      赔偿  1 * 4:

Jam&#39;s math problem(思维)

Jam's math problem Submit Status Practice HDU 5615 Description Jam has a math problem. He just learned factorization.  He is trying to factorize  into the form of .  He could only solve the problem in which p,q,m,k are positive numbers.  Please help

HDU 5349 MZL&#39;s simple problem(优先队列)

MZL's simple problem Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 776    Accepted Submission(s): 375 Problem Description A simple problem Problem Description You have a multiple set,and now