Pa求助,为什么我只有70分

P1307 [NOIP2011 普及组] 数字反转

贺李果子 @ 2015-10-24 10:05:20

var s:string;
    i,j,k:integer;
begin
  readln(s);
  k:=length(s);
  if (s[1]='-') then write('-');
  for i:=k downto 1 do begin
    if (s[i]>='1') and (s[i]<='9') then write(s[i]);
  end;
end.

by gdygdy @ 2015-10-24 11:04:04

[ pic=20]


by gdygdy @ 2015-10-24 11:05:15

[codec ]


by gdygdy @ 2015-10-24 11:06:02

[codec ]printf("%s","Hello world!")[/codec ]


by leningrad @ 2015-10-25 16:11:14

中间的0无法显示


by huangzhewer @ 2015-11-10 12:41:25

var s:string;
     c:char;
    i:longint;
begin
  read(c);
 read(s);
 if c='-' then write('-')
           else s:=c+s;
  for i:=length(s) downto 1 do
    if (s[i]='0')then delete(s,i,1)
                  else break;
   for i:=length(s) downto 1 do
      write(s[i]);
end.

by 胡重阳 @ 2016-01-09 23:08:37

这道题为什么要用字符串呢,这样写也可以啊。

var
n,a,b,fan:int64;
begin
readln(n);
a:=n;
b:=0;
fan:=1;
if a<0 then
 begin
 a:=-a;
 fan:=-1;
 end;
  while (a>0) do
   begin
   b:=b*10+ a mod 10;
   a:=a div 10;
   end;
fan:=fan*b;
writeln(fan);
end.

by cbx8888 @ 2016-01-10 16:13:35

中间的0不用去除掉


by ALLEN @ 2016-02-12 20:42:20

中间的0不用去除掉,而且downto 到2.


by team109 @ 2019-08-28 22:44:03

考古:你谷唯一一个discussid=年份的


by Toclhu @ 2020-04-09 13:23:02

考古!


| 下一页