program kursovaya;
uses crt;
var nPunkt,KeyAscii,i:integer;
    Key:char;
    a,b,c:string;
    Xmin,Xmax,s:real;
    x,y:array[1..235] of real;

procedure About;
begin
 clrscr;
 Textcolor(3);
 GotoXY (22,7);
 Write('Kursovaya rabota po informatike');
 GotoXY (15,8);
 Write('"Raschet znacheniya funkcii i postroenie ee graphica"');
 GotoXY (40,17);
 Write ('Prepodavtel Sluzhenikina N.V.');
 GotoXY (40,18);
 Write('Vipolnila studentka gruppi St-110103');
 GotoXY (40,19);
 Write ('Ogoreltseva Maria');
 GotoXY(27,25);
 Write ('Ekaterinburg 2012');
 Readln;
end;

procedure Vvod_dannih (var a1,b1,c1:real);
var o:integer;
    a,b,c:string;
begin
  clrscr;

  repeat
  clrscr;

  repeat
  clrscr;
  GotoXY (15,5);
  Textcolor(3);
  Write ('Vvedite nizhni predel Xmin   ');
  Readln (a);
  Val (a,a1,o);
  if o<>0 then begin
  GotoXY (15,15);
  Textcolor(4);
  write('Vveden nechislovoi format. Povtorite vvod');
  readln;
  end;
  until o=0;

  repeat
  clrscr;
  GotoXY (15,6);
  Textcolor(3);
  Write ('Vvedite verhni predel Xmax   ');
  Readln (b);
  Val (b,b1,o);
  if o<>0 then begin
  GotoXY (15,15);
  Textcolor(4);
  write ('Vveden nechislovoi format. Povtorite vvod');
  readln;
  end;
  until o=0;
  if Xmin>Xmax then begin
  GotoXY(15,15);
  Textcolor(4);
  write('Xmax dolzhen bit bolshe Xmin. Povtorite vvod');
  Readln;
  end;
  until Xmin<Xmax;

  repeat
  clrscr;

  repeat
  clrscr;
  GotoXY (15,7);
  Textcolor(3);
  Write ('Vvedite shag izmeneniya funkcii s   ');
  readln(c);
  Val (c,c1,o);
  if o<>0 then begin
  GotoXY (15,15);
  Textcolor(4);
  write ('Vveden nechislovoi format. Povtorite vvod');
  readln;
  end;
  until o=0;
  If (Xmax-Xmin)<s then begin
  GotoXY(15,15);
  Textcolor(4);
  Write ('Shaaaaag');
  Readln;
  end;
  until(Xmax-Xmin)>s;
 end;

 procedure Raschet (Xmin,Xmax,s:real; var x,y:array of real);
 var
 f,i,k:integer;
     m,n: real;
 begin
 clrscr;
  Textcolor(3);
  f:=trunc((Xmax-Xmin)/s+1);
  m:=Xmin;
  k:=1;
 For i:=1 to f do
 begin
 if m=0 then begin
 m:=m+s;
 GotoXY(25,k);
 write ('Razriv funkcii');
 k:=k+1;
 end;
  n:=((3*sqr(m)-6)/2*m);
  x[i]:=m;
  y[i]:=n;
  GotoXY(25,k);
  writeln ('x=',x[i]:5:2,'  ','y= ',y[i]:5:2);
  m:=m+s;
  k:=k+1;
  If i=20 or 30 then readln;
 end;
 Readln;
 end;

 {procedure Graphik (Xmin,Xmax:real);
 var gd,gm: integer;
 begin
  gm:=2;
  InitGraph(gd,gm,'');

 end;}



begin
  clrscr;
  nPunkt:=1;

repeat
  clrscr;
  if nPunkt=1 then Textcolor(3) else TextColor(2);
  GotoXY(30,7);
  Writeln('O programme');
  if nPunkt=2 then Textcolor(3) else TextColor(2);
  GotoXY(30,8);
  Writeln('Vvod dannih');
  if nPunkt=3 then Textcolor(3) else TextColor(2);
  GotoXY(30,9);
  Writeln('Rachet');
  if nPunkt=4 then Textcolor(3) else TextColor(2);
  GotoXY(30,10);
  Writeln('Graphic');
  if nPunkt=5 then Textcolor(3) else TextColor(2);
  GotoXY(30,11);
  Writeln('Vihod');

  Key:=ReadKey;
  KeyAscii:=Ord(key);
  if KeyAscii=0 then
  begin
    Key:=ReadKey;
    KeyAscii:=Ord(Key);
  end;

  if KeyAscii=80 then nPunkt:=nPunkt+1;
  if KeyAscii=72 then nPunkt:=nPunkt-1;

  if nPunkt>5 then nPunkt:=1;
  if nPunkt<1 then nPunkt:=5;

  if KeyAscii=13 then
   begin
    if nPunkt=1 then About;
    if nPunkt=2 then Vvod_dannih (Xmin,Xmax,s);
    if nPunkt=3 then Raschet (Xmin,Xmax,s,x,y);
    {if nPunkt=4 then Graphik;}
    if nPunkt=5 then Exit;
   end;
  until (KeyAscii=113) or (KeyAscii=27);
  ReadKey;
  end.


