Witam.
Napisałem moduł, który zawiera procedurę obliczeń związanych z funkcją kwadratową oraz narysowaniem odpowiedniego wykresu. Nie umiem wywołać teraz tej procedury z modułu.
Dołączam załącznik z kodem źródłowym modułu.
Co powinienem zrobić ??
unit fkwadratowa_modul;
interface
uses crt,graph;
procedure calosc(a,b,c,x1,x2,x0,delta:Real; tryb,sterownik:smallint);
implementation
procedure calosc(a,b,c,x1,x2,x0,delta:Real; tryb,sterownik:smallint);
begin
writeln;
writeln(' PROGRAM LICZACY MIEJSCA ZEROWE FUNKCJI KWADRATOWEJ I RYSUJACY JEJ WYKRES');
writeln;
writeln(' ax2+bx+c=0 <---musisz podac jego parametry a,b i c');
writeln;
writeln(' parametr a MUSI BYC ROZNY OD ZERA !!!!!!');
write(' a wynosi: ');
readln(a);
write(' b wynosi: ');
readln(b);
write(' c wynosi: ');
readln(c);
delta:=b*b-4*a*c;
writeln;
writeln(' delta wynosi ',delta:100:2);
writeln;
if (delta>0) and(a>0) then
begin
x1:=-b-sqrt(delta)/2*a;
x2:=-b+ sqrt(delta)/2*a;
writeln(' funkcja ma 2 miejsca zerowe');
writeln(' mianowicie: ');
writeln;
writeln('-> x1=',x1:10:2);
writeln('-> x2=',x2:10:2);
detectgraph(sterownik,tryb);
initgraph(sterownik,tryb,'');
setcolor(14);
line(100,200,400,200);
line(400,200,370,180);
line(400,200,370,220);
OutTextXY(410,200,'os X');
SetColor(Magenta);
OutTextXY(130,180,'x1/x2');
OutTextXY(270,180,'x1/x2');
setcolor(red);
ellipse(220,130,180,360,40,140);
setcolor(5); {kropka nr1}
Circle(185,200,4);
SetFillStyle(CloseDotFill,5);
FloodFill(185,200,5);
setcolor(5); {kropka nr2}
Circle(255,200,4);
SetFillStyle(CloseDotFill,5);
FloodFill(255,200,5);
readln;
end;
if (delta>0) and(a<0) then
begin
x1:=-b-sqrt(delta)/2*a;
x2:=-b+ sqrt(delta)/2*a;
writeln(' funkcja ma 2 miejsca zerowe');
writeln(' mianowicie:');
writeln;
writeln('-> x1=',x1:10:2);
writeln('-> x2=',x2:10:2);
detectgraph(sterownik,tryb);
initgraph(sterownik,tryb,'');
setcolor(14);
line(100,200,400,200);
line(400,200,370,180);
line(400,200,370,220);
OutTextXY(410,204,'os X');
SetColor(Magenta);
OutTextXY(130,180,'x1/x2');
OutTextXY(270,180,'x1/x2');
setcolor(red);
ellipse(220,280,0,180,40,140);
setcolor(5); {kropka nr1}
Circle(187,200,4);
SetFillStyle(CloseDotFill,5);
FloodFill(187,200,5);
setcolor(5); {kropka nr2}
Circle(253,200,4);
SetFillStyle(CloseDotFill,5);
FloodFill(253,200,5);
readln;
end;
if (delta=0) and(a>0) then
begin
x0:=-b/2*a;
writeln(' funkcja ma 1 miejsce zerowe ');
writeln(' mianowicie: ');
writeln;
writeln('-> x0=',x0:10:2);
detectgraph(sterownik,tryb);
initgraph(sterownik,tryb,'');
setcolor(14);
line(100,200,400,200);
line(400,200,370,180);
line(400,200,370,220);
OutTextXY(410,200,'os X');
SetColor(Cyan);
OutTextXY(215,205,'x0');
setcolor(red);
ellipse(220,60,180,360,40,140);
setcolor(3);
Circle(220,200,4);
SetFillStyle(hatchFill,3);
FloodFill(220,200,3);
readln;
closegraph;
end;
if (delta=0) and(a<0) then
begin
x0:=-b/2*a;
writeln(' funkcja ma 1 miejsce zerowe ');
writeln(' mianowicie: ');
writeln;
writeln('-> x0=',x0:10:2);
detectgraph(sterownik,tryb);
initgraph(sterownik,tryb,'');
setcolor(14);
line(100,200,400,200);
line(400,200,370,180);
line(400,200,370,220);
OutTextXY(410,200,'os X');
SetColor(Cyan);
OutTextXY(215,205,'x0');
setcolor(red);
ellipse(220,340,0,180,40,140);
setcolor(3);
Circle(220,200,4);
SetFillStyle(hatchFill,3);
FloodFill(220,200,3);
readln;
closegraph;
end;
if (delta<0) and(a>0) then
begin
writeln(' funkcja nie ma miejsc zerowych');
detectgraph(sterownik,tryb);
initgraph(sterownik,tryb,'');
setcolor(14);
line(100,200,400,200);
line(400,200,370,180);
line(400,200,370,220);
OutTextXY(410,200,'os X');
SetColor(LightMagenta);
OutTextXY(215,205,'NO NI MA MIEJSC ZEROWCH :P');
setcolor(red);
ellipse(220,20,180,360,40,140);
readln;
closegraph;
end;
if (delta<0) and(a<0) then
begin
writeln(' funkcja nie ma miejsc zerowych');
detectgraph(sterownik,tryb);
initgraph(sterownik,tryb,'');
setcolor(14);
line(100,200,400,200);
line(400,200,370,180);
line(400,200,370,220);
OutTextXY(410,200,'os X');
SetColor(LightMagenta);
OutTextXY(215,205,'NO NI MA MIEJSC ZEROWCH :P');
setcolor(red);
ellipse(220,400,0,180,40,140);
readln;
closegraph;
end;
end;
end.
przeniesienie kodu z załącznika do posta
- @furious programming