• API
• FAQ
• Tools
• Archive
daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. program u;
2. uses oglgraph;
3. var xf, yf, xfmax, xfmin, kx, ky, dxf : real;
4.     xe, ye, xr, yr, xrmax, yrmax, gd, gm, x0, y0: integer;
5.
6. function f(x: real) : real;
7. begin
8.   if ((3 * x * x - 1) = 0) then f := 0
9.   else f := 1 / (3 * x * x - 1)
10. end;
11. BEGIN
12.
13.
14.   dxf := 0.0005;
15.   xfmax := 2;
16.   xfmin := -2.5;
17.   xr := 100;
18.   yr := 100;
19.   xrmax := 300;
20.   yrmax := 500;
21.   kx := (xrmax - xr)/(xfmax - xfmin);
22.   ky := kx;
23.   y0 := (yr + yrmax) div 2;
24.   if ((xfmin < 0) and (xfmax > 0)) then x0 := round(xr -xfmin * kx);
25.
26.   gm := detectmode;
27.   gd := detect;
28.   initgraph(gd, gm, '');
29.   rectangle(xr, yr, xrmax, yrmax);
30.   line(xr, y0, xrmax,  y0);
31.   line(x0, yr, x0, yrmax);
32.   {drawx}
33.   setcolor(red);
34.   line(round(x0 + kx), y0 - 5, round(x0 + kx), y0 + 5);
35.   line(round(x0 - kx), y0 - 5, round(x0 - kx), y0 + 5);
36.   line(round(x0 + 2*kx), y0 - 5, round(x0 + 2*kx), y0 + 5);
37.   line(round(x0 - 2*kx), y0 - 5, round(x0 - 2*kx), y0 + 5);
38.
39.
40.   line(x0 - 5, round(y0 + ky), x0 + 5, round(y0 + ky));
41.   line(x0 - 5, round(y0 - ky), x0 + 5, round(y0 - ky));
42.   line(x0 - 5, round(y0 + 2*ky), x0 + 5, round(y0 + 2*ky));
43.   line(x0 - 5, round(y0 - 2*ky), x0 + 5, round(y0 - 2*ky));
44.
45.   xf := xfmin;
46.   while(xfmax >= xf) do begin
47.     yf := f(xf);
48.     xe := x0 + round(xf * kx);
49.     ye := y0 - round(yf * ky);
50.     if((ye < yrmax) and (ye > yr)) then putpixel(xe, ye, green);
51.     xf += dxf;
52.     writeln(xe,' ', ye);
53.     writeln(xf);
54.     writeln(xfmax);
55.     writeln(xfmax - xf);
56.   end;
57.