пятница, 27 мая 2011 г.

ПАРОЛЬ: Ханты-мансийск! С4. Кому нужно, тот поймет...

СРОЧНО!!!
program c4;
var s,c : string;
    i,p,q,r,d,e,j : integer;
    x1,x2 : real;
    f : TextFile;
begin
  assignfile(f,'input.txt');
  reset(f);
  readln(f,s);
  p:=0;
  q:=0;
  r:=0;
  i:=1;
  c:='';
  while (s[i]<>'a') do
    begin
      c:=c+s[i];
      inc(i);
    end;
  Val(c,p,e);
  if p=0 then p:=1;
  inc(i);
  c:='';
  while (s[i]<>'b') do
    begin
      c:=c+s[i];
      inc(i);
    end;
  Val(c,q,e);
  c:='';
  inc(i);
  for j:=i to Length(s) do
    begin
    c:=c+s[j];
    end;
  Val(c,r,e);
  d:=q*q-4*p*r;
  closefile(f);
  append(f);
  writeln(f);
  if d>0 then
    begin
      x1:=(-q-sqrt(d))/(2*p);
      x2:=(-q+sqrt(d))/(2*p);
      writeln(f,x1);
      writeln(f,x2);
    end;
  if d=0 then
    begin
      x1:=(-q)/(2*p);
      writeln(f,x1);
    end;
  closefile(f);
end.