文章
6
粉丝
94
获赞
2
访问
2.0k
#include<bits/stdc++.h>
using namespace std;
int main() {
string s;
int count = 0;
cin >> s;
string s1 = s;
reverse(s.begin(), s.end());//翻转s字符串
int n1, n2, sum;
while (s != s1) {
n1 = stoi(s1);//字符串转数字函数
n2 = stoi(s);
sum = n1 + n2;
count++;
s = s1 = to_string(sum);//将数字转化为字符串
reverse(s.begin(), s.end());
}
cout << count << " " << s;
return 0;
}
登录后发布评论
暂无评论,来抢沙发