- 数字反转
- 2014-03-07 21:09:46 @
#include <iostream>
using namespace std;
char a[20];
int main(int argc,char *argv[])
{
int i;
bool k=0;
cin>>a;
if(a[0]=='-')
{
k=1;
cout<<"-";
}
strrev(a+k);
for(i=k;i<strlen(a+k);i++)
{
if(a[i]!='0')
break;
}
cout<<a+i<<endl;
system("pause");
return 0;
}
100分
1 条评论
-
幻影F绝杀 LV 8 @ 2014-10-29 20:23:14
var
a:string;
b:array[1..255]of integer;
c,i,s:integer;
begin
readln(a);
if a[1]='-' then
begin
write('-');
c:=2;
end
else c:=1;
s:=length(a);
for i:=c to s do
b[i]:=ord(a[i])-48;
i:=s;
while b[i]=0 do
begin
s:=s-1;
i:=i-1;
end;
for i:=s downto c do write(b[i]);
end.
- 1