why_working @ 2020-02-03 17:20:31
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
int main()
{
string s;
cin>>s;
if(s[0]=='-'&&s[s.length()-1]!='0');
{
reverse(s.begin()+1,s.end());
cout<<s;
}
if(s[0]=='-'&&s[s.length()-1]=='0')
{
reverse(s.begin()+1,s.end());
s.erase(1);
cout<<s;
}
if(s[0]!='-'&&s[s.length()-1]=='0')
{
reverse(s.begin(),s.end());
s.erase(0);
cout<<s;
}
if(s[0]!='-'&&s[s.length()-1]!='0')
{
reverse(s.begin(),s.end());
cout<<s;
}
system("pause");
return 0;
}
输入123 输出132231
输入-120 输出-021
求大佬解惑555
by 吴勉之 @ 2020-02-03 17:30:20
老哥erase不是这么玩的。。。
by fa_555 @ 2020-02-03 17:32:58
草,cppreference 请
https://zh.cppreference.com/w/cpp/string/basic_string/erase
by _短笛无腔_ @ 2020-02-03 17:43:53
你瞎加个
by why_working @ 2020-02-03 19:09:20
@fa_555 请问一下为什么输入123会输出132231?
by Clintikas97 @ 2020-02-09 16:20:51
https://www.luogu.com.cn/discuss/show/187954
by 扫雷王子 @ 2020-08-03 18:55:58
在神帖隔壁
by zrq4024 @ 2020-12-26 11:35:39
几分钟后,一个神贴诞生
by siyu0816 @ 2022-09-18 17:20:49
???