Witam. Otóż napisałem program w pascalu, który po naciśnięciu odpowiedniego klawisza liczy pole przypisanej mu figury. Kod wygląda następująco:
program Project1;{$APPTYPE CONSOLE}uses SysUtils; var a:real; q,w,e,r,t,y,u,i,o,p,l,k,j,h:real; procedure dane;begin writeln ('jesli chcesz policzyc pole kwadratu to nacisnij 1, jesli chcesz policzyc pole prostokata to nacisnij 2, jesli chcesz policzyc pole trojkata to nacisnij 3, jesli chcesz policzyc pole trapezu to nacisnij 4, jesli chcesz policzyc pole kola, to nacisnij 5:'); readln (a); if (a=1) then begin writeln ('podaj dlugosc boku a:'); readln (q); if (q<=0) then begin writeln ('zle parametry'); readln; dane; end; end; begin dane; w:=q*q; writeln ('pole wynosi:', w:3:3); readln; end; if (a=2) then begin writeln ('podaj dlugosc boku a oraz boku b:'); readln (e); readln (r); if (e<=0) or (r<=0) then begin writeln ('zle parametry'); readln; dane; end; end; begin dane; t:=e*r; writeln ('pole prostokata wynosi:', t:3:3); readln; end; if (a=3) then begin writeln ('podaj dlugosc podstawy a, wysokosc h:'); readln (y); readln (u); if (y<=0) or (u<=0) then begin writeln ('zle parametry'); readln; dane; end; end; begin dane; i:=y*u/2; writeln ('pole trojkata wynosi:', i:3:3); readln; end; if (a=4) then begin writeln ('podaj dlugosci podstaw a,b oraz dlugosc wysokosci h:'); readln (o); readln (p); readln (l); if (o<=0) or (p<=0) or (l<=0) then begin writeln ('zle parametry'); readln; dane; end; end; begin dane; k:=(o+p)*l/2; writeln ('pole trapezu wynosi:', k:3:3); readln; end; if (a=5) then begin writeln ('podaj dlugosc promienia r:'); readln (j); if (j<=0) then begin writeln ('zle parametry'); readln; dane; end; end; begin dane; h:=Pi*j*j; writeln ('pole kola wynosi:', h:3:3); readln; end; if (a>5) then begin writeln ('miales podac liczbe z przedzialu od 1 do 5!'); readln; end;end.Problem tkwi w tym, ze gdy odpalam program wyskakuje okienko i odrazu znika, może ktoś wie, co z tym zrobić?
PS. Pisze w Delphi 7
PS. Bez procedury zabezpieczjącej przed wpisywaniem ujemnych liczby wszystko było OK.