大佬们,wa三个呀,这是为啥??

P1307 [NOIP2011 普及组] 数字反转

等等,还有更短的代码。 @[daniel2014](/user/1236790) ```cpp #include<bits/stdc++.h> using namespace std; string s; int main(){ cin>>s; if(s.size()==1&&s[0]=='0') cout<<'0'; else{ if(s[0]=='-'){ s.erase(0,1); reverse(s.begin(),s.end()); for(int i=0;s[0]=='0';++i) s.erase(0,1); cout<<'-'<<s; }else{ reverse(s.begin(),s.end()); for(int i=0;s[0]=='0';++i) s.erase(0,1); cout<<s; } } return 0; } ```
by Sci_8633 @ 2024-03-15 20:07:08


知道了,谢谢!!
by daniel2014 @ 2024-03-16 20:25:43


|