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 1248. Sequence Sum

Почему моя программа выдаёт неправельный ответ на 6 вопрос?
Posted by Criss009 8 Apr 2013 22:09
Почему моя программа выдаёт неправельный ответ на 6 вопрос?
Re: Почему моя программа выдаёт неправельный ответ на 6 вопрос?
Looks like there is some bug in it =)))
Re: Почему моя программа выдаёт неправельный ответ на 6 вопрос?
Posted by Criss009 9 Apr 2013 17:42
program p1;
type tabel=array[-100..100] of byte;
var r,eror,s,a,c,i,num,b:integer;  n,pr:string; x:tabel;
procedure insertare(var t:tabel; f:string; p:integer);
var q,e,i:integer;
begin
for i:=1 to length(f) do
begin
s:=0;
val(f[length(f)-i+1],q,e);
if t[i+p-1]+q+s<=9 then begin t[i+p-1]:=t[-1+i+p]+q+s; s:=0; end
else begin t[i+p-1]:=t[i+p-1]+q+s-10; s:=1; end;
end;
while s<>0 do begin
inc(i);
if t[i+p-1]+s<=9 then begin t[i+p-1]:=t[i+p-1]+s; s:=0; end
else begin t[i+p-1]:=t[i+p-1]+s-10; s:=1; end;
end;
end;

begin
s:=0;
for i:=-100 to 100 do x[i]:=0;
readln(num);
for i:=1 to num do
begin
readln(n);  a:=pos('e',n);
val(copy(n,pos('e',n)+1,length(n)),b,eror);
if pos('.',n)<>0 then begin
                      pr:=copy(n,1,pos('.',n)-1);
                      insertare(x,pr,b);
                      pr:=copy(n,pos('.',n)+1,a-pos('.',n)-1);
                      insertare(x,pr,b-(a-pos('.',n)-1));
                       end else
                       begin
                       pr:=copy(n,1,pos('e',n)-1);
                       insertare(x,pr,b);
                       end;

end;
for i:=100 downto -100 do
if x[i]<>0 then if x[i-20]>5 then insertare(x,'1',i-19);
for i:=100 downto -100 do
if x[i]<>0 then  begin
write(x[i],'.');
for c:=i-1 downto i-19 do
write(x[c]);
write('e');
if i<>0 then write(i);
break;
end;
readln;
end.

Why, test please and tell me why it don't work