旧巷听风丶 @ 2018-11-06 21:12:23
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
string s;
cin>>s;
reverse(s.begin(),s.end());
while(s[0]=='0'&&s.size()>0)s.erase(0,1);
cout<<s;
return 0;
}
by 旧巷听风丶 @ 2018-11-06 21:12:47
刚学OI求助
by The_Stardust @ 2018-11-06 21:13:58
负号的问题吧
by The_Stardust @ 2018-11-06 21:14:23
hack 数据:-123
by YU401 @ 2018-11-06 21:17:04
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
string s;
cin>>s;
reverse(s.begin(),s.end());
while(s[0]=='0'&&s.size()>0)s.erase(0,1);
if(s[0]>0)
cout<<"-";
for(int i=0;i<s.size()-1;i++)
{
cout<<s[i];
}
return 0;
}
by YU401 @ 2018-11-06 21:17:12
试一试
by YU401 @ 2018-11-06 21:24:38
不好意思写错了
by YU401 @ 2018-11-06 21:25:06
不要在意上面的程序
by 寒落 @ 2018-11-06 21:28:22
@旧巷听风丶 负数先把负号去掉(输出)就行了
by lycx03 @ 2019-02-15 16:26:47
注意下负数
by 飞友737ng @ 2019-08-27 14:24:52
using namespace std; int main() { int a,b; cin>>a>>b; while(a!=0){ b=b*10; b=b+a%10; a=a/10; } cout<<b<<endl; }