program linearnafunkcija;
uses crt,graph;
var driver,mode,xc,yc,i:integer;
    k,n,x,y:real;
begin
  ClrScr;
  writeln(' Ovaj program crta graf funkcije y=k*x+n ');
  writeln;
  write(' Unesi parametre funkcije (k,n):');
  readln(k,n);
  driver:=detect;
  initgraph(driver,mode,'');
  xc:=(GetMaxX+1) div 2;
  yc:=(GetMaxY+1) div 2;
  setbkcolor(black);
  setcolor(white);
  line(xc,0,xc,GetMaxY);
  line(0,yc,GetMaxX,yc);
  for i:=-(xc div 10) to (xc div 10) do
    begin
      moveto(xc+10*i,yc);
      linerel(0,round(-3));
      moveto(xc,yc-round(10*i));
      linerel(3,0)
    end;
  x:=-xc;
  for i:=-xc to xc do
    begin
      x:=0.1*i;
      y:=k*x+n;
      PutPixel(xc+round(x*10),yc-round(y*10),15);
    end;
  readln;
  closegraph
end.