题解 | #反序相等# int->string->int

反序相等

https://www.nowcoder.com/practice/092e7068881549bd8985c379208ef3c2

#include <iostream>
#include<string>
#include<algorithm>
using namespace std;

int reverse_(int x){
    string str=to_string(x);
    reverse(str.begin(),str.end());
    return stoi(str);
}

int main() {
    for(int i=1000;i<9999;++i){
        if (i*9==reverse_(i)){
            cout<<i;
            break;
        }
    }
}

全部评论

相关推荐

牛马43373018...:这人真懂什么叫熵吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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