题目1089:数字反转(简单数字转换)
题目链接: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 ****************************************************************/
作者: 伊甸一点
出处: http://www.cnblogs.com/zpfbuaa/
本文版权归作者伊甸一点所有,欢迎转载和商用(须保留此段声明),且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
原文链接 如有问题, 可邮件(zpflyfe@163.com)咨询.