Advertisement
Guest User

Untitled

a guest
Oct 19th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.33 KB | None | 0 0
  1. program grafika1024x768_256kolorow;
  2. Uses crt,graph;
  3. var
  4.  tryb,u,l,i,n,ymax,ymin,nw,nn,a,b     :integer;
  5.  y:real;
  6.  tab:array[1..20] of -10000..10000;
  7.  tay:array[1..20] of 0..740;
  8.  taw:array[1..20] of 0..520;
  9. {-------------Wymuszenie trybu 256 kolorow-------------}
  10. {$f+}
  11. function detectsvga256:integer;
  12. begin
  13.   detectsvga256:=tryb;
  14. end;
  15. {$f-}
  16.  
  17. {-------------Procedura startowa-----------------------}
  18. procedure start;
  19. var
  20.  autodetect:pointer;
  21.  ster:integer;
  22. begin
  23.   tryb:=3;
  24.   autodetect:=@detectsvga256;
  25.   ster:=installuserdriver('svga256',autodetect);
  26.   initgraph(ster,tryb,'');
  27. end;
  28.  
  29. {-------------Program glowny -------------------------}
  30. Begin
  31.  clrscr;
  32.  randomize;
  33.   repeat
  34.    writeln('Podaj ilosc pomiarow(n od 5 do 20)');
  35.    readln(n);
  36.    if (n>20) or (n<5) then writeln('Zla wartosc, n musi miescic sie w przedzile <5,20>');
  37.   until (n<=20) and (n>=5);
  38.   repeat
  39.    writeln('Podaj wartosc minimalna(ymin od -10000 do 10000)');
  40.    readln(ymin);
  41.    if (ymin>10000) and (ymin<-10000) then writeln('Zla wartosc, ymin musi miescic sie w przedzile <-10000,10000>');
  42.   until (ymin<=10000) and (ymin>=-10000);
  43.   repeat
  44.    writeln('Podaj wartosc maksymalna(ymax od -10000 do 10000 i wieksza od ymin)');
  45.    readln(ymax);
  46.    if (ymax>10000) or (ymax<-10000) then
  47.    writeln('Zla wartosc, ymax musi miescic sie w przedzile <-10000,10000>');
  48.   until (ymax<=10000) and (ymax>=-10000);
  49.   for i:=1 to n do
  50.   tab[i]:=random(ymax-ymin)+ymin+1;
  51.   clrscr;
  52.   for i:=1 to n do
  53.    writeln('tab[',i,']=',tab[i]);
  54.   nn:=tab[1];
  55.   nw:=tab[1];
  56.   for i:=1 to n do
  57.    begin
  58.    if tab[i]<nn then nn:=tab[i];
  59.    if tab[i]>nw then nw:=tab[i];
  60.    end;
  61.   writeln('Wartosc najwyzsza to ',nw,', a najnizsza to ',nn);
  62.   if (nn<0) and (nw>0) then l:=round(nw/(nw+abs(nn))*520+40) else
  63.    if nn>0 then l:=540 else l:=40;
  64.   writeln('L to ',l);
  65.   readln;
  66.   start;
  67.   setcolor(white);
  68.   line(30,l,770,l);
  69.   line(30,20,30,580);
  70.   line(25,25,30,20);
  71.   line(35,25,30,20);
  72.   line(765,l-5,770,l);
  73.   line(765,l+5,770,l);
  74.   u:=740 div (2*n);
  75.   tay[1]:=0;
  76.   for i:=1 to n do
  77.    tay[i]:=tay[i-1]+u;
  78.   for i:=1 to n do
  79.    taw[i]:=round(tay[i]/(nw+abs(nn))*520);
  80.   for i:=1 to n do
  81.   begin
  82.   if tab[i]>=0 then
  83.   bar3d(u+30,l-tay[i],2*u+30,l,10,topon);
  84.   u:=u+u;
  85.   if tab[i]<=0 then
  86.   bar3d(u+30,l,2*u+30,l+tay[i],10,topon);
  87.   end;
  88.   readln;
  89. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement