
题意很简单,就是反转数字,但末尾的零不能反转.
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
string in;
int t;
cin>>t;
while (t--) {
cin>>in;
auto s=in.begin(),e=in.end();
if(in[0]=='-'){
s++;
e--;
while(e!=s){
if(*e=='0'){
e--;
}
else{
break;
}
}
reverse(s, ++e);
cout<<in<<endl;
}
else{
e--;
while(e!=s){
if(*e=='0'){
e--;
}
else{
break;
}
}
reverse(s, ++e);
cout<<in<<endl;
}
}
return 0;
}




近期评论