文章

5

粉丝

0

获赞

8

访问

305

头像
翻转数的和 题解:
P1003 兰州大学机试题
发布于2025年3月11日 13:51
阅读数 29

//方法一 使用string

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

int main(){
    string a,b;
    while(cin>>a>>b){
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        cout<<stoi(a)+stoi(b)<<endl;
    }    
    return 0;    

//法二传统

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

int getReverse(int n){
    int temp = 0;
    int sum = 0;
    while(n>0){
        temp = n%10;
        sum = sum*10+temp;        
        n/=10;
    }
    return sum;
...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发