您的位置:首页 > 其它

题目1089:数字反转(简单数字转换)

2017-05-04 21:17 155 查看
题目链接:http://ac.jobdu.com/problem.php?pid=1089

详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus

参考代码:

//
//  1089 数字反转.cpp
//  Jobdu
//
//  Created by PengFei_Zheng on 04/05/2017.
//  Copyright © 2017 PengFei_Zheng. All rights reserved.
//

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

int reverse(int x){
int tmp = x;
int ans = 0;
while(tmp!=0){
ans = ans*10 + tmp%10;
tmp/=10;
}
return ans;
}
int n;
int main(){
scanf("%d",&n);
while(n--){
int a,b;
scanf("%d %d",&a,&b);
int sum = a+b;
reverse(sum) == reverse(a) + reverse(b) ? printf("%d\n",sum) : printf("NO\n");
}
}
/**************************************************************
Problem: 1089
User: zpfbuaa
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: