ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1074. Very Short Problem

I go WA!!! Help me plese give some tests!
Posted by Algorithmus_UA(algorithmus@univ.kiev.ua) 16 Aug 2002 03:10
---------------------My PROGRAM---------------
var s,tmp,tmp2,sss,yo:string;
    point,i,j,e,err,N:integer;
    _end:boolean;
    ch2:char;
procedure prost(X:integer);
var ch:Char;
begin
  yo:='';
  ch:=' ';
  if (s[x] = '+')or(s[x] = '-') then
  begin
    ch:=s[x];inc(X);
  end;
  tmp:='';point:=-1;_end:=false;
  for i:=x to length(s) do if s[i] in ['0'..'9','.']then
  begin
    if s[i]<>'.' then tmp:=tmp+s[i];
    if (s[i] = '.')and(point = -1) then point:=length(tmp)
    else if s[i] = '.' then
    begin
      yo:='Not a floating point number';
      exit;
    end;if i = length(s)then _end:=true;
  end else break;
  if  (length(tmp)= point)or(tmp = '') then
  begin
    yo:=yo+'Not a floating point number';
    exit;
  end;
  if not _end then
  begin
    if (s[i] = 'e')or(s[i] = 'E') then
    begin
      x:=i+1;
      ch2:=' ';
      if (s[x] = '+')or(s[x] = '-') then
      begin
        ch2:=s[x];inc(X);
      end;
      tmp2:='';_end:=false;
      for i:=x to length(s) do if s[i] in ['0'..'9']then
      begin
        tmp2:=tmp2+s[i];
{        if (s[i] = '.')and(point = -1) then point:=i
        else if s[i] = '.' then
        begin
          writeln('Not a floating point number');
          exit;
        end;}
        if i = length(s) then _end:=true;
      end else
      begin
        yo:=yo+'Not a floating point number';
        exit;
      end;

      if _end = false then
      begin
        yo:=yo+'Not a floating point number';
        exit;
      end;
      if ch = '-' then yo:=yo+(ch);
      if point = -1 then point:=length(tmp);
      val(tmp2,e,err);
      if ch2 = '-' then e:=-e;
      point:=point+e;
      i:=1;
      for i:=1 to point+1 do if tmp[i] <> '0' then break;
      sss:='';point:=point-i+1;
      for j:=i to length(tmp) do sss:=sss+tmp[j];
      tmp:=sss;
      if point<=0 then
      begin
        yo:=yo+('0');
        if N<>0 then
        begin
          yo:=yo+('.');
          i:=0;
          for i:=1 to abs(point) do if i<=N then yo:=yo+('0') else
exit;
          x:=i;
          for i:=1 to length(tmp) do if x+i<=N then yo:=yo+(tmp[i])
else exit;
          x:=x+i;
          for i:=x+1 to N do yo:=yo+('0');
          exit;
        end;
      end
      else
      begin
        _end:=false;
        for i:=1 to point do
        if i<=length(tmp) then
        begin
           yo:=yo+(tmp[i]);
           if i = length(tmp) then _end:=true;
        end
        else yo:=yo+'0';
        if N = 0 then exit
        else
        begin
          if _end then
          begin
            yo:=yo+('.');
            for i:=1 to N do yo:=yo+('0');
          end
          else
          begin
            yo:=yo+('.');
            x:=i;_end:=false;
            for i:=1 to N do
            if x+i<=length(tmp) then
            begin
              yo:=yo+(tmp[x+i]);
              if i = N then _end:=true;
            end
            else break;
            if _end then exit
            else
            begin
              x:=i;
              for i:=x to N do yo:=yo+('0');
            end;
          end;
        end;
      end;
    end
    else
    begin
      yo:=yo+('Not a floating point number');
      exit;
    end;
  end
  else
  begin
      if ch = '-' then yo:=yo+(ch);
      if point = -1 then point:=length(tmp);
{      val(s2,e,err);
      if ch2 = '-' then e:=-e;
      point:=point+e;}
      i:=1;
      for i:=1 to {length(tmp)}point+1 do if tmp[i] <> '0' then break;
      sss:='';point:=point-i+1;
      for j:=i to length(tmp) do sss:=sss+tmp[j];
      tmp:=sss;
      if point<=0 then
      begin
        yo:=yo+('0');
        if N<>0 then
        begin
          yo:=yo+('.');
          i:=1;
          for i:=1 to abs(point) do if i<=N then yo:=yo