Eugeniusz Jakubas |
Stąd można pobrać teksty źródłowe poniższych 57 programów w Pascalu pr-pascal.zip - 34 kB
45. Wklęsłość - wypukłość funkcji
Program wkleslosc_wypuklosc; {$N+} uses Graph; var karta,tryb,n,siatka,j,kolor:integer; x,y,dx,y1,y2,y3,xpp:extended; function f(x:extended):extended; begin f:=x*x/(2*x*x-x-2); end; begin karta:=detect; initGraph(karta,tryb,'c:\tp\bgi'); j:=20; setColor(darkGray); for n:=-320 div j to 320 div j do line(n*j+320,0,n*j+320,479); for n:=-240 div j to 240 div j do line(0,n*j+240,639,n*j+240); setColor(white); line(0,240,639,240); line(320,0,320,479); x:=-320/j; Dx:=0.00025; repeat x:=x+Dx; y:=f(x); y1:=f(x+Dx); y2:=f(x+2*Dx); y3:=f(x+3*Dx); if y1-y>y2-y1 then kolor:=yellow else kolor:=lightRed; xpp:=(2*x+3*Dx)/2; if abs(y)<240/j then putPixel(round(xpp*j+320),round(-f(xpp)*j+240),kolor); if (((y2-y1<y1-y) and (y2-y1<y3-y2)) or ((y2-y1>y1-y) and (y2-y1>y3-y2))) and (abs(y)<240/j) and (abs(y1)<240/j) and (abs(y2)<240/j) and (abs(y3)<240/j) then writeLn('xpp=',xpp:18:14,', ypp=',f(xpp):18:14); until x>320/j; readln; closeGraph; end. |