题解 | 23年OPPO-a的翻转

23年OPPO-a的翻转

https://www.nowcoder.com/practice/dcce2d0cc8f740c29e0885df96c9d625

//  #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  string s;//---------以字符串形式读取A
  cin >> s;
  string ss = s;
  reverse(s.begin(), s.end());//----------------反转获得B
  long long a, b;
  a = stoi(s);//-------------把字符串转回数字
  b = stoi(ss);
  a += b;//--------相加,开ll防溢出
  cout << a;
  return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 评论 收藏
分享
在等offer的火锅...:我去履历这么好,都找不到工作吗?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务