P1553,看起来简单,为什么做不到100。。。无力吐糟,求指导
  • 板块灌水区
  • 楼主wswhy
  • 当前回复0
  • 已保存回复0
  • 发布时间2015/2/14 21:07
  • 上次更新2023/10/22 10:18:02
查看原帖
P1553,看起来简单,为什么做不到100。。。无力吐糟,求指导
3440
wswhy楼主2015/2/14 21:07

源代码:

var
  s:string;
  i,op,c,w,w2,d:integer;
begin
  readln(s);
  op:=0;
  for i:=1 to length(s) do
  begin
  if s[i]='.' then begin op:=1; break; end;
  if s[i]='/' then begin op:=2; break; end;
  if s[i]='%' then begin op:=3; break; end;
  end;
  if op=0 then
  begin
  for i:=length(s) downto 1 do
  if s[i]<>'0' then begin c:=i; break; end;
  for i:=c downto 1 do write(s[i]);
  halt;
  end;
  if op=1 then
  begin
    for i:=1 to length(s) do if s[i]='.' then begin c:=i; break; end;
     for i:=c-1 downto 1 do
  if s[i]<>'0' then begin d:=i; break; end;
  for i:=d downto 1 do write(s[i]);
  write('.');
  for i:=c+1 to length(s) do if s[i]<>'0' then begin w:=i; break; end;
  for i:=length(s) downto w do write(s[i]);
  halt;
  end;
  if op=2 then
  begin
    for i:=1 to length(s) do if s[i]='/' then begin c:=i; break; end;
    for i:=c-1 downto 1 do if s[i]<>'0' then begin w:=i; break; end;
    for i:=w downto 1 do write(s[i]); write('/');
     for i:=length(s) downto c+1 do if s[i]<>'0' then begin w:=i; break; end;
    for i:=w downto c+1 do write(s[i]);
  halt;
  end;
  if op=3 then
  begin
  for i:=length(s)-1 downto 1 do
  if s[i]<>'0' then begin c:=i; break; end;
  for i:=c downto 1 do write(s[i]);
  write('%');
  halt;
  end;
  end.

2015/2/14 21:07
加载中...