PROGRAM Sinus;
USES Graph, CRT; { $i PAS:Graph }

CONST
    k1 = 40;   k2 = 100;
    KD : Integer = Detect;
    MD : Integer = Detect;

VAR
    i, j, s : Integer;
    c : Char;
    Tab : ARRAY [0..1000] OF Integer;
    ox, oy : Integer;

function Sign (X: Integer): Integer;
     { выдает знак числа X }
   begin
     if X > 0 then Sign := 1
     else
       if X < 0 then Sign := -1
       else
         Sign := 0;
   end;

BEGIN
    InitGraph (KD,MD,'');
    ox := (GetMaxX + 1) DIV 2;
    oy := (GetMaxY + 1) DIV 2;
    FOR i := 1 TO ox-10 DO
	Tab [I] := Round (Sin (i / k1)*k2);
    SetColor(Green);
    FOR i := 1 TO ox-10 DO BEGIN
	s := Tab [i];
	IF s <> 0 THEN BEGIN
	    Line (i+ox, s+oy, ox, oy+Sign (s));
	    Line (ox-i, oy-s, ox, oy-Sign (s));
	END;
    END;
    SetColor (Yellow);
    Line (0, oy, GetMaxX+1, oy);
    Line (ox, 0, ox, GetMaxY+1);
    Line (GetMaxX-4, oy-3, GetMaxX, oy-1);
    Line (GetMaxX-4, oy+3, GetMaxX, oy+1);
    Line (ox-3, 5, ox-1, 1);
    Line (ox+3, 5, ox+1, 1);

    c := ReadKey;
    CloseGraph
END.