文章

20

粉丝

0

获赞

64

访问

11.5k

头像
数字反转 题解:
P1276 上海交通大学机试题
发布于 2026年3月
阅读数 633

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a,b;
    while(cin>>a>>b){
        int c=a+b;
        string ss=to_string(c);
        reverse(ss.begin(),ss.end());
        int y=stoi(ss);
        string s1=to_string(a);
        string s2=to_string(b);
        reverse(s1.begin(),s1.end());
         reverse(s2.begin(),s2.end());
         int a1=stoi(s1);
         int a2=stoi(s2);
         int x=a1+a2;
         if(x==y){
            cout<<c<<endl;
         }else{
            cout<<"NO"<<endl;
  &nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发