题解 | #反序相等#
反序相等
https://www.nowcoder.com/practice/092e7068881549bd8985c379208ef3c2
#include <iostream> #include <cstring> #include <sstream> #include <string> #include <algorithm> using namespace std; int main() { for ( int i = 1000; i <= 1111; i ++ ){ string s = to_string(i); //数字转换成字符串 reverse(s.begin(),s.end()); //反转字符串 int x = stoi(s); //字符串转换成数字 默认是10进制 if ( i*9 == x ) cout << i << endl; //符合题意 输出 } return 0; }