见贤思琦 @ 2019-10-02 09:32:59
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1;
cin>>s1;
int flag=1;
if(s1[0]=='-')
{
cout<<s1[0];
reverse(s1.begin(),s1.end());
for(int i=1;i<s1.length();i++)
if((!flag||s1[i]!='0')&&s1[i]!='-')
{
cout<<s1[i];
flag=0;
}
}
else
{
reverse(s1.begin(),s1.end());
for(int i=0;i<s1.length();i++)
if(!flag||s1[i]!='0')
{
cout<<s1[i];
flag=0;
}
}
}
by tidongCrazy @ 2019-10-02 09:42:40
@见贤思琦 你输入-1看一下会输出什么
by tidongCrazy @ 2019-10-02 09:44:25
把
for(int i=1;i<s1.length();i++)
if((!flag||s1[i]!='0')&&s1[i]!='-')
{
cout<<s1[i];
flag=0;
}
中改为
for(int i=0;i<s1.length();i++)
by PtrZ @ 2019-10-02 09:49:22
using namespace std;
int n,k;
int main()
{
cin>>n;
while(n)
{
k=k*10+n%10;
n/=10;
}
cout<<k<<endl;
}
by tidongCrazy @ 2019-10-02 09:57:09
@jishengbin 请别用Markdown来强调头文件的重要性(滑稽)