jzcrq @ 2020-03-25 18:06:26
#include<bits/stdc++.h>
using namespace std;
int main(){
char a;
int b=10001,c[10001]={};
while(scanf("%c",&a)!='\n'){
if (a=='-'){
cout<<"-";
c[b]='-';
goto d;
}
if (b==10001&&a=='0'){
cout<<"0";
return 0;
}
b--;
if (b=='0') c[b]=0;
if (a=='1') c[b]=1;
if (a=='2') c[b]=2;
if (a=='3') c[b]=3;
if (a=='4') c[b]=4;
if (a=='5') c[b]=5;
if (a=='6') c[b]=6;
if (a=='7') c[b]=7;
if (a=='8') c[b]=8;
if (a=='9') c[b]=9;
d:a=a;
if (a=='\n') goto c;
}
c:for (int d=b;d<=10000;d++){
if (c[d]!=0)
cout<<c[d];
else if (c[d]==0&&d!=b&&d!=10000) cout<<c[d];
}
return 0;
}
30分,但是好像没什么问题啊
by xhQYm @ 2020-03-25 18:07:28
枚举?!
by liqingyang @ 2020-03-25 18:07:46
@lscrq 我谔谔
by xhQYm @ 2020-03-25 18:08:03
汗(lll¬ω¬)
by xhQYm @ 2020-03-25 18:08:31
参考我的代码吧,枚举太恶心了:
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
cin>>a;
int len=a.size();
if(a[0]=='-')
{
printf("-");
bool flag=true;
for(int i=len-1;i>=1;i--)
{
if(a[i]=='0' and flag==true){continue;}
else cout<<a[i];
if(a[i]!='0') flag=false;
}
}
else
{
bool flag=true;
for(int i=len-1;i>=0;i--)
{
if(a[i]=='0' and flag==true){continue;}
else cout<<a[i];
if(a[i]!='0') flag=false;
}
}
return 0;
}
by james1BadCreeper @ 2020-03-25 18:08:43
tql
by asasas @ 2020-03-25 18:10:26
大佬们代码这么长。。
by __gcd @ 2020-03-25 18:11:33
循环不好吗……
by jzcrq @ 2020-03-25 18:14:33
@liqingyang “我谔谔”是什么意思
by liqingyang @ 2020-03-25 18:26:55
@qym2008 代码有些长?
我的:
#include<iostream>
using namespace std;
int main()
{
int n,ans=0;
cin>>n;
if(n<0)
{
cout<<"-";
n*=-1;
}
while(n)
{
ans=ans*10+n%10;
n/=10;
}
cout<<ans<<endl;
return 0;
}
by PrincessYR✨~ @ 2020-03-25 18:27:02
看我的代码吧:
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
long long a,b,c=0,d;
cin>>a;
do
{
c=c*10+a%10;
a=a/10;
}while(a!=0);
cout<<c;
return 0;
}