JRY___萌主 @ 2016-08-26 13:44:47
入门菜鸟一只向大神求教~为什么只有七十分啊
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int n,i;
cin>>n;
if(n<0){
n=-n;
cout<<"-";
}
do{
i=n%10;
if(i!=0)
cout<<i;
n=n/10;
}while(n!=0);
return 0;
}
by JRY___萌主 @ 2016-08-26 13:45:32
求教大神
by Yoshinow2001 @ 2016-08-26 21:43:00
举个反栗:23330333
by 不佚名 @ 2016-09-13 16:00:36
改long long
by frankchenfu @ 2016-09-16 13:52:34
要加一个判断是前导零还是中间零,我加了一个bool,初始化为false,然后if(i!=0||b==true) {b=true;cout<<i};
by 谢宇峰2016 @ 2016-09-26 19:50:00
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,o;
int main()
{
cin>>n;
if(n<0)
{
o=1;
n=abs(n);
}
if(n==0)
{
cout<<n;
return 0;
}
if (n>0)
{
if(o==1) cout<<"-";
while(n>0)
{
if(n%10!=0)
{
break;
}
n=n/10;
}
while(n>0)
{
cout<<n%10;
n=n/10;
}
}
return 0;
//前导零注意!!!
}