to_string+stoll
2025-07-28 17:54:07
发布于:浙江
0阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
if (n<0){
cout<<'-';
string s=to_string(n);
s.erase(s.begin());
reverse(s.begin(),s.end());
int i=stoll(s);
cout<<i;
}else{
string s=to_string(n);
reverse(s.begin(),s.end());
int i=stoll(s);
cout<<i;
}
return 0;
}
这里空空如也
有帮助,赞一个