Kerwin__17 @ 2016-10-22 16:17:14
#include<iostream>
#include<cstring>
using namespace std;
char a[20] ;
bool fu = 0 ;
int l;
int main( ){
gets(a);
l=strlen(a);
if(a[0]=='-')
cout<<'-';
for(int i=l;i>=0;i--)
{
if(a[i]>='1'&&a[i]<='9'){
cout<<a[i];
}
}
return 0;
}
by Kerwin__17 @ 2016-10-22 17:41:52
这个程序是个半残,加上需要cstdio库,兼职不能看
by Kerwin__17 @ 2016-10-22 17:42:30
已经AC
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char b[200],a[200];
int l,head=0;
int main() {
int temp=0;
gets(b);
l=strlen(b);
for(int i=l; i>=0; i--) {
if(b[0]=='-'&&temp==0) {
a[head++]='-';
temp=1;
}
if(b[i]>='0'&&b[i]<='9')
a[head++]=b[i];
}
for(int i=0; i<=l; i++) {
if(a[i]=='-')
continue;
if(a[i]=='0')
a[i]=0;
if(a[i+1]!='0')
break;
}
if(a[0]=='-')
cout<<'-';
for(int i=0; i<=head; i++)
if(a[i]>='0'&&a[i]<='9')
cout<<a[i];
return 0;
}