Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

FNT 2015 CodeEU Zanimljiva informatika - 04 Ivan Damnjanovic - Tenis progam kod

222 views

Published on

Forum naprednih tehnologija, Niš 2015,
Evropska nedelja programiranja (codeEU, CodeWeekEU),
Otvoreni čas programiranja - Zanimljiva informatika - PDIS
Oni su deo budućnosti
Elektronski fakultet, Niš
sreda 14.10.2015.godine

Published in: Education
  • Be the first to comment

FNT 2015 CodeEU Zanimljiva informatika - 04 Ivan Damnjanovic - Tenis progam kod

  1. 1. program tennis_math; function verovatnoca(x,y:real):real; var gemx,gemy,tajbx,tajby,setxdob0,setxdob1,setxgub1,setxgub0:real; setydob1,setydob0,setygub0,setygub1:real; i,j,h:integer; v:array[0..10,0..10] of real; r:array[0..10,0..10,1..2] of real; begin //Racunamo verovatnoce za gemove gemx:=-x*x*x*x*(2*x-3)*(5-8*x+4*x*x)/(1-2*x+2*x*x); gemy:=-y*y*y*y*(2*y-3)*(5-8*y+4*y*y)/(1-2*y+2*y*y); //Racunamo verovatnoce za tajbrejkove for i:=0 to 7 do for j:=0 to 7 do v[i,j]:=0; v[0,0]:=1; for i:=0 to 6 do for j:=0 to 6 do if ((i+j) mod 4 = 0) or ((i+j) mod 4 = 3) then begin v[i+1,j]:=v[i+1,j]+v[i,j]*x; v[i,j+1]:=v[i,j+1]+v[i,j]*(1-x); end else begin v[i+1,j]:=v[i+1,j]+v[i,j]*(1-y); v[i,j+1]:=v[i,j+1]+v[i,j]*y; end; tajbx:=v[6,6]*x*(1-y)/(x*(1-y)+y*(1-x)); for i:=0 to 5 do tajbx:=tajbx+v[7,i]; for i:=0 to 7 do for j:=0 to 7 do v[i,j]:=0;
  2. 2. v[0,0]:=1; for i:=0 to 6 do for j:=0 to 6 do if ((i+j) mod 4 = 0) or ((i+j) mod 4 = 3) then begin v[i+1,j]:=v[i+1,j]+v[i,j]*y; v[i,j+1]:=v[i,j+1]+v[i,j]*(1-y); end else begin v[i+1,j]:=v[i+1,j]+v[i,j]*(1-x); v[i,j+1]:=v[i,j+1]+v[i,j]*x; end; tajby:=v[6,6]*y*(1-x)/(x*(1-y)+y*(1-x)); for i:=0 to 5 do tajby:=tajby+v[7,i]; //Racunamo verovatnoce za setove for i:=0 to 7 do for j:=0 to 7 do v[i,j]:=0; v[0,0]:=1; for i:=0 to 5 do for j:=0 to 5 do if (i+j) mod 2 = 0 then begin v[i+1,j]:=v[i+1,j]+v[i,j]*gemx; v[i,j+1]:=v[i,j+1]+v[i,j]*(1-gemx); end else begin v[i+1,j]:=v[i+1,j]+v[i,j]*(1-gemy); v[i,j+1]:=v[i,j+1]+v[i,j]*gemy; end; setxdob1:=v[6,1]+v[6,3]+v[5,5]*(1-gemx-gemy+gemx*gemy*2)*tajbx; setxdob0:=v[6,0]+v[6,2]+v[6,4]+v[5,5]*gemx*(1-gemy); setxgub1:=v[1,6]+v[3,6]+v[5,5]*(1-gemx-gemy+gemx*gemy*2)*(1-tajbx);
  3. 3. setxgub0:=v[0,6]+v[2,6]+v[4,6]+v[5,5]*gemy*(1-gemx); for i:=0 to 7 do for j:=0 to 7 do v[i,j]:=0; v[0,0]:=1; for i:=0 to 5 do for j:=0 to 5 do if (i+j) mod 2 = 0 then begin v[i+1,j]:=v[i+1,j]+v[i,j]*gemy; v[i,j+1]:=v[i,j+1]+v[i,j]*(1-gemy); end else begin v[i+1,j]:=v[i+1,j]+v[i,j]*(1-gemx); v[i,j+1]:=v[i,j+1]+v[i,j]*gemx; end; setydob1:=v[6,1]+v[6,3]+v[5,5]*(1-gemx-gemy+gemx*gemy*2)*tajby; setydob0:=v[6,0]+v[6,2]+v[6,4]+v[5,5]*gemy*(1-gemx); setygub1:=v[1,6]+v[3,6]+v[5,5]*(1-gemx-gemy+gemx*gemy*2)*(1-tajby); setygub0:=v[0,6]+v[2,6]+v[4,6]+v[5,5]*gemx*(1-gemy); //Racunamo verovatnocu za mec for i:=0 to 3 do for j:=0 to 3 do begin r[i,j,1]:=0; r[i,j,2]:=0; end; r[0,0,1]:=1; r[0,0,2]:=0; for i:=0 to 2 do for j:=0 to 2 do begin r[i+1,j,1]:=r[i+1,j,1]+setxdob0*r[i,j,1]+setygub1*r[i,j,2]; r[i+1,j,2]:=r[i+1,j,2]+setxdob1*r[i,j,1]+setygub0*r[i,j,2];
  4. 4. r[i,j+1,1]:=r[i,j+1,1]+setxgub0*r[i,j,1]+setydob1*r[i,j,2]; r[i,j+1,2]:=r[i,j+1,2]+setxgub1*r[i,j,1]+setydob0*r[i,j,2]; end; verovatnoca:=r[3,0,1]+r[3,0,2]+r[3,1,1]+r[3,1,2]+r[3,2,1]+r[3,2,2]; end; var a,b:real; begin write('Uneti verovatnocu da prvi igrac dobije poen kad servira: '); readln(a); write('Uneti verovatnocu da drugi igrac dobije poen kad servira: '); readln(b); writeln('Verovatnoca da prvi igrac dobije mec iznosi: ',verovatnoca(a,b):0:3); end.

×