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

could you have a look?
Posted by testing~ 29 Mar 2004 19:59
this is my code
who can give me some data? thanks !

program A_very_short_problem ;
  const
    nono = 'Not a floating point number';
  var
    s   : ansistring;
    jj,j1   : boolean;
    i,j,k,l,jin : integer;
  function ok(q,h : integer) : boolean ;
    var
      i : integer;
    begin
      ok:=false;
      for i:=q to h do if s[i] in ['0'..'9'] then else exit;
      ok:=true;
    end;
  begin
//    assign(input,'pp.txt'); reset(input);
    readln(s);
    while s<>'#' do
      begin
        j:=pos('e',s); l:=length(s);
        if j=0 then j:=pos('E',s);
        if (j<>0)and(j<l)
           then if ok(j+2,l)and(s[j+1] in ['0'..'9','+','-'])and
                   ((j<l-1)or(s[j+1] in ['0'..'9']))
                   then begin
                          jin:=0; i:=j+1;
                          if s[i]='-' then jj:=false
                             else begin
                                    jj:=true;
                                    if s[i]<>'+' then jin:=ord(s[i])-48;
                                  end;
                          while i<l do
                            begin
                              inc(i); jin:=jin*10+ord(s[i])-48;
                            end;
                        end
                   else begin writeln(nono); readln(j); readln(s); continue; end
           else j:=l+1;
        delete(s,j,l-j+1); l:=j-1;
        if l=0 then begin writeln(nono); readln(j); readln(s); continue; end;
        k:=pos('.',s);
        if ((k=1)or(s[1] in ['0'..'9','-','+']))and ok(2,k-1)and ok(k+1,l)and(k<l)
           then else begin writeln(nono); readln(j); readln(s); continue; end;
        if s[1] in ['+','-'] then
           begin
             if s[1]='-' then j1:=true else j1:=false;
             delete(s,1,1);
           end else j1:=false;
        k:=pos('.',s); l:=length(s);
        if k=0 then k:=l+1
           else begin delete(s,k,1); dec(l); end;
        if jj then inc(k,jin) else dec(k,jin);
        while k<=0 do begin s:='0'+s; inc(k); end;
        while k>l+1 do begin s:=s+'0'; inc(l); end;
        if k=1 then s:='0.'+s else
        if k=l+1 then s:=s+'.0' else insert('.',s,k);
        while s[1]='0' do delete(s,1,1);
        if s[1]='.' then s:='0'+s;
        l:=length(s); k:=pos('.',s);
        readln(j);
        for i:=1 to k+j do
          if (i<>k)and(i<=l)
              then if s[i]<>'0' then begin i:=-1; break; end else
              else break;
        if i=-1 then if j1 then write('-');
        for i:=1 to k-1 do write(s[i]);
        if j>0 then write(s[k]);
        for i:=k+1 to k+j do if i<=l then write(s[i]) else write('0');
        writeln;
        readln(s);
      end;
  end.