1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
PROGRAM poleTrojkataWedlePolaHerona; USES crt; VAR a, b, c: real; function wprowadz(bok:char): real; VAR x: real; begin repeat Write('Podaj dlugosc boku ', bok, ': '); readln(x); if(x<0) then writeln('Pewnys/pewnas? A jeszcze raz wpisz.'); until x>0; wprowadz:=x; end; function sprawdzCzyIstnieje(x,y,z: real): boolean; begin if((x+y>=z) and (y+z>=x) and (z+x>=y)) then sprawdzCzyIstnieje:=true else sprawdzCzyIstnieje:=false; end; function pole(x,y,z:real): real; VAR p: real; begin p:=(x+y+z)/2; pole:=sqrt(p*(p-x)*(p-y)*(p-z)); end; begin clrscr; repeat a:=wprowadz('a'); b:=wprowadz('b'); c:=wprowadz('c'); if sprawdzCzyIstnieje(a,b,c)=false then WriteLn('Trojkat o podanych bokach nie istnieje. Sprobuj jeszcze raz.'); until sprawdzCzyIstnieje(a,b,c)=true; WriteLn('Pole tego tr˘jkĄta to ', pole(a,b,c):5:5, '.'); ReadLn; end. |