program tkxgrafs;               {Auswahl von Thermospannungsmeáwerten}
                                {die mit TKMGRAF3 durchgefhrt wurden}
                                {bei šberkreuzmessung mit Maus}
uses  dos,crt,graph;


const mxhi=100;myhi=100;hh1=15;hh2=15;myh=35;imaxx=100;

var US,tem1,tem2,ur,Strom,dt : real;
    b1,b2: char;
    Name,name1,name2: string;
    tex,tex2 :Text;
    i,l,anz,anz0,b3,b4,ap,ep,b5,b6,b7,b8:integer;
    bera,berz: array[1..100] of integer;
    zeit,ut,tm1,tm2: array[1..2*imaxx] of Real;
    alpha,T:real;
    dtem,uth:array[1..2*imaxx] of real;
    num:array[1..2*imaxx] of integer;
    f : text;
    z0,z1,z2,z3,z4,z5: real;
    time,time1,time2:real;

var graphdriver,graphmode:integer;
    mx,my,mym,xp,yp,x0,y0,j,find,nr,find1:integer;
    r,dx,dy,xl,yl,invdifx,xminT,xminU,xmaxT,xmaxU,yminT,ymaxT:real;
    xmin,xmax,x,y,ymin,ymax,difx,dify,invdify,deltax,deltay,yminU,ymaxU:real;
    strxmin,strxmax,stryminT,strymaxT,stryminU,strymaxU,strr,sanz,strb4:string;
    sxmin,sxmax,syminT,symaxT,syminU,symaxU,xr,yr,zx,zy,zxy,zxx,a,zeit1:real;
    symin,symax,rr,dTi,Ui,m,n:real;
    MausX, MausY,delti,nreins,nrzwei,imax: Integer;
    regs: Registers;
    farbe,punkt:word;
    wahl:array[1..2*imaxx]of word;

procedure ig;
begin
graphdriver:=detect;
initgraph(graphdriver,graphmode,'c:\sprachen\tp\bgi');
end;

function kor(t_m1,t_m2:real):real;
 var ergebnis:real;
begin
if b8=1 then ergebnis:=0 else begin
 ergebnis:=z0*(t_m1-t_m2);
 ergebnis:=ergebnis+z1*(sqr(t_m1)-sqr(t_m2))/2;
 ergebnis:=ergebnis+z2*(t_m1*sqr(t_m1)-t_m2*sqr(t_m2))/3;
 ergebnis:=ergebnis+z3*(sqr(t_m1*t_m1)-sqr(t_m2*t_m2))/4;
 ergebnis:=ergebnis+z4*(t_m1*sqr(t_m1*t_m1)-t_m2*sqr(t_m2*t_m2))/5 ;
 ergebnis:=ergebnis+z5*(sqr(t_m1*t_m1*t_m1)-sqr(t_m2*t_m2*t_m2))/6 ;
end;
 kor:=ergebnis;
end;

procedure punkteins;
begin
delti:=abs(mausx-round(mxhi-xmin*invdifx));
nreins:=1;
for i:=2 to 2*imax do begin
if abs(mausx-round(mxhi+(zeit[i]-zeit[1]-xmin)*invdifx))<delti then begin
delti:= abs(mausx-round(mxhi+(zeit[i]-zeit[1]-xmin)*invdifx));
nreins:=i;end;
end;
wahl[nreins]:=10;
for find:=1 to 3 do begin
if (nr=9) or (nr=10) or (nr=11) then begin
i:=nreins;
    x:=zeit[i]-zeit[1];
    if nr=9 then begin
    ymax:=ymaxU;ymin:=yminU;invdify:=(mym-myhi)/(ymax-ymin);
    end;
    if (nr=10) or (nr=11) then begin
    ymax:=ymaxT;ymin:=yminT;invdify:=(my-mym)/(ymax-ymin);
    end;
if nr=9 then y:=ut[i];
if nr=10 then y:=tm1[i];
if nr=11 then y:=tm2[i];
    x:=mxhi+(x-xmin)*invdifx;xp:=round(x);
if nr=9 then y:=myhi+(ymax-y)*invdify;yp:=round(y);
if nr>9 then y:=mym+(ymax-y)*invdify;yp:=round(y);
farbe:=getcolor;
setcolor(wahl[i]);
circle(xp,yp,2);
setcolor(farbe);
{if num[i]/10-int(num[i]/10)=0 then begin
for j:=myhi to my do putpixel(xp,j,7);end;
moveto(xp,yp);}
end;
nr:=nr+1;end;
nr:=nr-3;
punkt:=1;end;

procedure punktzwei;
begin  punkt:=2;
delti:=abs(mausx-round(mxhi-xmin*invdifx));
nrzwei:=1;
for i:=2 to 2*imax do begin
if abs(mausx-round(mxhi+(zeit[i]-zeit[1]-xmin)*invdifx))<delti then begin
delti:= abs(mausx-round(mxhi+(zeit[i]-zeit[1]-xmin)*invdifx));
nrzwei:=i;end;
end;
{b5:=abs(nreins-nrzwei);}
if abs(nreins-nrzwei)>3 then begin
if nreins<nrzwei then begin
   for i:=nreins to nrzwei do begin
   wahl[i]:=10; end;
   for find:=1 to 3 do begin
if (nr=9) or (nr=10) or (nr=11) then begin
for i:=nreins to nrzwei do begin
    x:=zeit[i]-zeit[1];
    if nr=9 then begin
    ymax:=ymaxU;ymin:=yminU;invdify:=(mym-myhi)/(ymax-ymin);
    end;
    if (nr=10) or (nr=11) then begin
    ymax:=ymaxT;ymin:=yminT;invdify:=(my-mym)/(ymax-ymin);
    end;
if nr=9 then y:=ut[i];
if nr=10 then y:=tm1[i];
if nr=11 then y:=tm2[i];
    x:=mxhi+(x-xmin)*invdifx;xp:=round(x);
if nr=9 then y:=myhi+(ymax-y)*invdify;yp:=round(y);
if nr>9 then y:=mym+(ymax-y)*invdify;yp:=round(y);
farbe:=getcolor;
setcolor(wahl[i]);
{if x<mx/2 then} circle(xp,yp,2);
setcolor(farbe);
{if num[i]/10-int(num[i]/10)=0 then begin
for j:=myhi to my do putpixel(xp,j,7);end;
moveto(xp,yp);}
end;end;
nr:=nr+1;end;
nr:=nr-3;
end;
if nreins>nrzwei then begin
   for i:=nrzwei to nreins do begin
   wahl[i]:=10; end;
   for find:=1 to 3 do begin
if (nr=9) or (nr=10) or (nr=11) then begin
for i:=nrzwei to nreins do begin
    x:=zeit[i]-zeit[1];
    if nr=9 then begin
    ymax:=ymaxU;ymin:=yminU;invdify:=(mym-myhi)/(ymax-ymin);
    end;
    if (nr=10) or (nr=11) then begin
    ymax:=ymaxT;ymin:=yminT;invdify:=(my-mym)/(ymax-ymin);
    end;
if nr=9 then y:=ut[i];
if nr=10 then y:=tm1[i];
if nr=11 then y:=tm2[i];
    x:=mxhi+(x-xmin)*invdifx;xp:=round(x);
if nr=9 then y:=myhi+(ymax-y)*invdify;yp:=round(y);
if nr>9 then y:=mym+(ymax-y)*invdify;yp:=round(y);
farbe:=getcolor;
setcolor(wahl[i]);
{if x<mx/2 then} circle(xp,yp,2);
setcolor(farbe);
{if num[i]/10-int(num[i]/10)=0 then begin
for j:=myhi to my do putpixel(xp,j,7);end;
moveto(xp,yp);}
end;end;
nr:=nr+1;end;
nr:=nr-3;
end;

end;
end;

procedure punktdrei;
begin  punkt:=0;
for i:=1 to 2*imax do begin
if wahl[i]=10 then wahl[i]:=15;end;
   for find:=1 to 3 do begin
if (nr=9) or (nr=10) or (nr=11) then begin
for i:=1 to 2*imax do begin
    x:=zeit[i]-zeit[1];
    if nr=9 then begin
    ymax:=ymaxU;ymin:=yminU;invdify:=(mym-myhi)/(ymax-ymin);
    end;
    if (nr=10) or (nr=11) then begin
    ymax:=ymaxT;ymin:=yminT;invdify:=(my-mym)/(ymax-ymin);
    end;
if nr=9 then y:=ut[i];
if nr=10 then y:=tm1[i];
if nr=11 then y:=tm2[i];
    x:=mxhi+(x-xmin)*invdifx;xp:=round(x);
if nr=9 then y:=myhi+(ymax-y)*invdify;yp:=round(y);
if nr>9 then y:=mym+(ymax-y)*invdify;yp:=round(y);
farbe:=getcolor;
setcolor(wahl[i]);
{if x<mx/2 then} circle(xp,yp,2);
setcolor(farbe);
{if num[i]/10-int(num[i]/10)=0 then begin
for j:=myhi to my do putpixel(xp,j,7);end;
moveto(xp,yp);}
end;end;
nr:=nr+1;end;
nr:=nr-3;
end;

procedure MausEingabe;

begin
    regs.ax:=$01;intr($33,Regs);
    repeat
          regs.ax:=$03;intr($33,Regs);
    until regs.bx > 0;
    MausX := regs.cx;
    MausY := regs.dx;
    delay(100);
end;

procedure speichern;
begin  punkt:=0;
if nreins<nrzwei then b3:=nreins
else b3:=nrzwei;
if b4<100 then begin
bera[b4]:=b3-1+num[1]-1;
b5:=abs(nreins-nrzwei)+1;
berz[b4]:=b5;
b4:=b4+1;
end;
{b1:='a';}
for i:=1 to 2*imax do begin
if wahl[i]=10 then wahl[i]:=12;end;
   for find:=1 to 3 do begin
if (nr=9) or (nr=10) or (nr=11) then begin
for i:=1 to 2*imax do begin
    x:=zeit[i]-zeit[1];
    if nr=9 then begin
    ymax:=ymaxU;ymin:=yminU;invdify:=(mym-myhi)/(ymax-ymin);
    end;
    if (nr=10) or (nr=11) then begin
    ymax:=ymaxT;ymin:=yminT;invdify:=(my-mym)/(ymax-ymin);
    end;
if nr=9 then y:=ut[i];
if nr=10 then y:=tm1[i];
if nr=11 then y:=tm2[i];
    x:=mxhi+(x-xmin)*invdifx;xp:=round(x);
if nr=9 then y:=myhi+(ymax-y)*invdify;yp:=round(y);
if nr>9 then y:=mym+(ymax-y)*invdify;yp:=round(y);
farbe:=getcolor;
setcolor(wahl[i]);
{if x<mx/2 then} circle(xp,yp,2);
setcolor(farbe);
{if num[i]/10-int(num[i]/10)=0 then begin
for j:=myhi to my do putpixel(xp,j,7);end;
moveto(xp,yp);}
end;end;
nr:=nr+1;end;
nr:=nr-3;
end;

begin
 clrscr;
 writeln('Programm zur Auswertung von Thermospannungsmeáwerten, die mit');
 writeln('Hilfe des Programms tkmgraf3 bei alternierender Temperaturdifferenz');
 writeln('aufgenommen wurden.');
 rr:=0;
 writeln('Eingabe des Namen der Datei, in der sich die Meáwerte befinden, die');
 write('ausgewertet werden sollen (ohne .tkm): ');
 readln(name);
 write('Auswertung relative Thermokraft (1) / absolute Thermokraft (2) ');
 readln(b8);
 name1:=name + '.tkm';
 if b8=1 then name2:=name + '.rel' else name2:=name + '.abs';
 assign(tex,name1);assign(tex2,name2);
 writeln('Die ausgew„hlten Meáwerte werden in eine gleichnamige Datei mit der');
 writeln('Extension "rel" bzw. "abs" geschrieben.');

 b2:='j';while b2='j' do begin
 {for i:=1 to 100 do ers[i]:=0;}
 b4:=1;
 reset(tex);
{ write('Eingabe des ersten Meápunktes in der Grafik: ');
 readln(anz0);anz0:=anz0-1;}
 imax:=0;while (imax<10)or(imax>2*imaxx)do begin
 write('Eingabe der Meápunkte je Grafik (10<=imax<=',2*imaxx,'): ');
 readln(imax);end;imax:=round(imax/2);
{ writeln('- Nach Drcken von "e" wird der Grafikteil beendet.');
 writeln('- Nach Drcken von "l" kann ein Bereich ausgew„hlt werden, der fr die');
 writeln('  Berechnung eines alpha(T) verwendet werden soll. Geben Sie abwechselnd');
 writeln('  die Nummer des ersten Meápunktes und die Meápunktanzahl (max. 50) ein,');
 writeln('  als letzte Zahl "0" eingeben!');
 writeln('- Nach Drcken einer bel. anderen Taste erscheint die n„chste Grafik.');  }
 writeln('Es k”nnen bis zu 100 Bereiche gew„hlt werden.');
 readln;
 assign(f,'c:\daten\th_delta.txt');
 reset(f);
 readln(f,z0);
 readln(f,z1);
 readln(f,z2);
 readln(f,z3);
 readln(f,z4);
 readln(f,z5);
 close(f);
 time:=0;anz:=0;
 {seite:=0;weiter:=1;}
 punkt:=0;
 for i:=1 to 2*imax do wahl[i]:=15;
 b1:='a';
if anz=0 then begin
for i:=1 to imax do begin
  if not eof(tex) then begin
  readln(tex,anz);
  readln(tex,tem1);
  readln(tex,tem2);
  readln(tex,us);us:=us-kor(tem1,tem2);
  readln(tex,dt);
  readln(tex,rr);
  time:=time+dt;
  if i=1 then zeit1:=time;
  zeit[i+imax]:=time;
  tm1[i+imax]:=tem1;
  tm2[i+imax]:=tem2;
  ut[i+imax]:=us;
  num[i+imax]:=anz+1;
  wahl[i+imax]:=15;
  end;
  if eof(tex) then begin
  if i=1 then zeit1:=time;
  zeit[i+imax]:=time;
  tm1[i+imax]:=tem1;
  tm2[i+imax]:=tem2;
  ut[i+imax]:=us;
  end;
  end;
end;
while (b1<>'e') and (not eof(tex)) do begin
{if weiter=1 then begin
nreins:=nreins-imax;  }

  for i:=1 to imax do begin
  zeit[i]:=zeit[i+imax];
  tm1[i]:=tm1[i+imax];
  tm2[i]:=tm2[i+imax];
  ut[i]:=ut[i+imax];
  num[i]:=num[i+imax];
  wahl[i]:=wahl[i+imax];
  end;
  for i:=1 to imax do begin
  if not eof(tex) then begin
  readln(tex,anz);
  readln(tex,tem1);
  readln(tex,tem2);
  readln(tex,us);us:=us-kor(tem1,tem2);
  readln(tex,dt);
  readln(tex,rr);
  time:=time+dt;
  zeit[i+imax]:=time;
  tm1[i+imax]:=tem1;
  tm2[i+imax]:=tem2;
  ut[i+imax]:=us;
  num[i+imax]:=anz+1;
  wahl[i+imax]:=15;
  end;
  if eof(tex) then begin
  if i=1 then zeit1:=time;
  zeit[i+imax]:=time;
  tm1[i+imax]:=tem1;
  tm2[i+imax]:=tem2;
  ut[i+imax]:=us;
  end;
 { end;  }
end;
yminT:=tm1[1];ymaxT:=tm1[1];
for i:=1 to 2*imax do begin
if tm1[i]<yminT then yminT:=tm1[i];
if tm1[i]>ymaxT then ymaxT:=tm1[i];
if tm2[i]<yminT then yminT:=tm2[i];
if tm2[i]>ymaxT then ymaxT:=tm2[i];end;
ymaxT:=ymaxT+0.1;yminT:=yminT-0.1;
yminU:=ut[1];ymaxU:=ut[1];
for i:=1 to 2*imax do begin
if ut[i]<yminU then yminU:=ut[i];
if ut[i]>ymaxU then ymaxU:=ut[i];
end;
ymaxU:=ymaxU+0.1{*abs(ymaxU)};yminU:=yminU-0.1{*abs(yminU)};

{for i:=1 to imax do begin
   writeln('T1:',tm1[i],' T2:',tm2[i],' t:',zeit[i]);
   end;}
xmin:=-1;xmax:=zeit[2*imax]-zeit[1]+1;
{++++++++++++++++++++++++++}
nr:=9;
ig;
mx:=getmaxx;my:=getmaxy;mx:=mx-round(mxhi/2);
mym:=round(myh*(my-myhi)/100)+myhi;
for i:=mxhi to mx do begin putpixel(i,myhi,1);
                           putpixel(i,mym,1);
                           putpixel(i,my,1);end;
for i:=myhi to my do begin putpixel(mxhi,i,1);
                           putpixel(mx,i,1);end;

dx:=(xmax-xmin);
if dx>0 then begin
r:=1;
    if dx>=100 then begin
           while dx>=100 do begin
                            dx:=dx/10;
                            r:=r*10;
                            end;                           {Ermittlung des}
                     end;                                  {X-Rasters}
    while dx<10 do begin
                   dx:=dx*10;
                   r:=r/10;
                   end;
    if dx>50 then deltax:=10*r
    else if dx>20 then deltax:=5*r
    else deltax:=2*r;
    invdifx:=(mx-mxhi)/(xmax-xmin);
    find:=0;
    x:=int(xmin/deltax)*deltax;
    for j:=-1 to 12 do begin                               {Zeichnen des}
    xr:=x+j*deltax;                                        {X-Rasters und}
    xl:=mxhi+(-xmin+x+j*deltax)*invdifx;                   {Ermittlung der}
    x0:=round(xl);                                         {X-Skale}
    if (x0>=mxhi) and (x0<=mx) then begin
    if find=0 then begin sxmin:=xr;find:=1;end;
    sxmax:=xr;
    for i:=myhi to mym do begin
    putpixel(x0,i,8);
    end;
    for i:=mym to my do begin
    putpixel(x0,i,8);
    end;
    end;
    end;
x0:=round(mxhi-xmin*invdifx);
if (x0>=mxhi) and(x0<=mx) then begin
    for i:=myhi to my do begin
    putpixel(x0,i,4);
    end;
    end;
end;
{+++++++++++++++++++++++++++++}
for find1:=1 to 2 do begin
if nr=9 then begin ymax:=ymaxU;ymin:=yminU;end;
if nr=10 then begin ymax:=ymaxT;ymin:=yminT;end;          
xl:=mxhi+(-xmin+x+j*deltax)*invdifx;
dy:=ymax-ymin;
if dy>0 then begin
r:=1;
    if dy>=100 then begin
           while dy>=100 do begin
                            dy:=dy/10;
                            r:=r*10;
                            end;                           {Ermittlung des}
                     end;                                  {Y-Rasters}
    while dy<10 do begin
                   dy:=dy*10;
                   r:=r/10;
                   end;
    if dy>50 then deltay:=10*r
    else if dy>20 then deltay:=5*r
    else deltay:=2*r;
    y:=int(ymax/deltay)*deltay;
if nr=9 then invdify:=(mym-myhi)/(ymax-ymin);
if nr=10 then invdify:=(my-mym)/(ymax-ymin);
    find:=0;
    for j:=-1 to 12 do begin
    yr:=y-j*deltay;
 if nr=9 then yl:=myhi+(ymax-y+j*deltay)*invdify;
 if nr=10 then yl:=mym+(ymax-y+j*deltay)*invdify;
    y0:=round(yl);

if((nr=9)and(y0>=myhi)and(y0<=mym)) or ((nr=10)and(y0>=mym)and(y0<=my))
                               then begin                  {Zeichnen des}
    if find=0 then begin symax:=yr;find:=1;end;            {Y-Rasters und}
    symin:=yr;                                             {Ermittlung der}
 if nr=9 then begin syminU:=symin;symaxU:=symax;end;
 if nr=10 then begin syminT:=symin;symaxT:=symax;end;
    for i:=mxhi to mx do begin                             {Y-Skale}
    putpixel(i,y0,8);
    end;
    end;
    end;
if nr=9 then begin
y0:=round(myhi+ymax*invdify);
if (y0>=myhi) and (y0<=mym) then begin
    for i:=mxhi to mx do begin
    putpixel(i,y0,4);
    end; 
    end;end;
end;nr:=nr+1;end;nr:=nr-2;


for find:=1 to 3 do begin
if (nr=9) or (nr=10) or (nr=11) then begin
for i:=1 to 2*imax do begin
    x:=zeit[i]-zeit[1];
    if nr=9 then begin
    ymax:=ymaxU;ymin:=yminU;invdify:=(mym-myhi)/(ymax-ymin);
    end;
    if (nr=10) or (nr=11) then begin
    ymax:=ymaxT;ymin:=yminT;invdify:=(my-mym)/(ymax-ymin);
    end;
if nr=9 then y:=ut[i];                         { Zeichnen der }
if nr=10 then y:=tm1[i];
if nr=11 then y:=tm2[i];
    x:=mxhi+(x-xmin)*invdifx;xp:=round(x);                { Meáwerte }
if nr=9 then y:=myhi+(ymax-y)*invdify;yp:=round(y);
if nr>9 then y:=mym+(ymax-y)*invdify;yp:=round(y);
if i=1 then putpixel(xp,yp,15);
if i<>1 then lineto(xp,yp);
farbe:=getcolor;
setcolor(wahl[i]);
circle(xp,yp,2);
setcolor(farbe);
if num[i]/10-int(num[i]/10)=0 then begin
for j:=myhi to my do putpixel(xp,j,7);end;
moveto(xp,yp);
end;end;
nr:=nr+1;end;
nr:=nr-3;
str(rr:8:2,strr);str((num[2*imax]):6,sanz);
str(sxmin:8:2,strxmin);
str(sxmax:8:2,strxmax);
str(syminT:8:2,stryminT);
str(symaxT:8:2,strymaxT);
str(syminU:8:2,stryminU);
str(symaxU:8:2,strymaxU);
str(b4-1,strb4);
 settextstyle(1,horizdir,1);
settextjustify(lefttext,lefttext);
outtextxy(mxhi,myhi-hh1,strxmin);
settextjustify(righttext,lefttext);                    { Beschriftung des}
outtextxy(mx,myhi-hh1,strxmax);                         {  X-Y-Rasters    }
{ settextstyle(0,vertdir,1); }
settextjustify(righttext,righttext);
outtextxy(mxhi-hh1,mym+hh2,strymaxT);
outtextxy(mxhi-hh1,myhi,strymaxU);
settextjustify(righttext,lefttext);
outtextxy(mxhi-hh1,my,stryminT);
outtextxy(mxhi-hh1,mym-hh2,stryminU);


 settextstyle(1,horizdir,1);                            { Beschriftung der }
settextjustify(centertext,lefttext);                    { Grafik           }
outtextxy(round((mxhi+mx)/2),myhi-hh2,'t/s');
{ settextstyle(1,vertdir,1);}       
settextjustify(righttext,centertext);
outtextxy(mxhi-hh2,round((myhi+mym)/2),'U/æV');
outtextxy(mxhi-hh2,round((my+mym)/2),'T/K');
settextjustify(lefttext,centertext);
if tem1>=tem2 then begin
   outtextxy(mx+hh1,mym+2*hh2,'T1');outtextxy(mx+hh1,my-2*hh2,'T2');end;
if tem1<tem2 then begin
   outtextxy(mx+hh1,mym+2*hh2,'T2');outtextxy(mx+hh1,my-2*hh2,'T1');end;
outtextxy(mx+hh1,round((myhi+mym)/2),'Uth');
{outtextxy(15,15,'R/Ohm: ');}outtextxy(round(mx/2+115),15,'N = ');
{outtextxy(125,15,strr);}outtextxy(round(mx/2+155),15,sanz);
outtextxy(15,15,'ENDE');outtextxy(125,15,'WEITER');outtextxy(235,15,'SPEICHERN');
settextjustify(righttext,centertext);
outtextxy(mx,15,strb4);
regs.ax := $00; intr($33,Regs);
repeat
mauseingabe;
delay(100);
if ((mausx>mxhi)and(myhi<mausy)and(mausy<my)and(punkt=0))then punkteins else
if ((mausx>mxhi)and(myhi<mausy)and(mausy<my)and(punkt=1))then punktzwei else
if ((punkt=2)and not((mausx>230)and(mausx<340)and(mausy<30)))then punktdrei else
if ((mausx>230)and(mausx<340)and(mausy<30)and(punkt=2)) then speichern;
until ((mausy<30)and((mausx<230)and(punkt=0)));
if (mausx<120) then b1:='e';
closegraph;
end;
closegraph;
close(tex);
write('Neue Grafik?(j/n): ');
readln(b2);end;
writeln;
writeln('Moment bitte, ich rechne!');
rewrite(tex2);
{+++++++++++++++++++}
{for b5:=1 to 24 do begin
bera[b5]:=10*b5-9;
berz[b5]:=10;end;
b4:=25;}
{+++++++++++++++++++}
for b5:=1 to b4-1 do begin
   reset(tex);
   if bera[b5]>0 then begin
 for b7:=1 to bera[b5] do begin
  readln(tex,anz);
  readln(tex,tem1);
  readln(tex,tem2);
  readln(tex,us);us:=us-kor(tem1,tem2);
  readln(tex,dt);
  readln(tex,rr);
 end;end;
   T:=0;
   b6:=0;
   for i:=1 to berz[b5]do begin
   if not eof(tex) then begin
  readln(tex,anz);
  readln(tex,tem1);
  readln(tex,tem2);
  readln(tex,us);us:=us-kor(tem1,tem2);
  readln(tex,dt);
  readln(tex,rr);
   dtem[i]:=tem1-tem2;
   uth[i]:=us;
   T:=T+tem1+tem2;
   b6:=b6+1;
   end;
   end;berz[b5]:=b6;
{linreg+++++++++++++++++++++++++++++++}
zx:=0;zy:=0;zxy:=0;zxx:=0;                              {Berechnen der}
for i:=1 to berz[b5] do begin                           {Regressionsgeraden}
dTi:=dtem[i];Ui:=uth[i];
{if j=1 then Ui:=U[i];
if j=2 then begin if zdT>0 then Ui:=aT1[i];end;
if j=3 then begin if zdT>0 then Ui:=aT2[i];end;}
zx:=zx+dTi;
zy:=zy+Ui;
zxy:=zxy+dTi*Ui;
zxx:=zxx+dTi*dTi;
end;

m:=(berz[b5]*zxy-zx*zy)/(berz[b5]*zxx-zx*zx);
{n:=(zy-m*zx)/berz[b5]; }
{linreg ende++++++++++++++++++++++++++++++++++++}
  close (tex);
  alpha:=m;
  T:=T/(2*berz[b5]);
  writeln(tex2,alpha);writeln(tex2,T);
end;
close(tex2);
writeln;
writeln('Programmende.');
readln;
end.