Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program grafika1024x768_256kolorow;
- Uses crt,graph;
- var
- tryb,u,l,i,n,ymax,ymin,nw,nn,a,b :integer;
- y:real;
- tab:array[1..20] of -10000..10000;
- tay:array[1..20] of 0..740;
- taw:array[1..20] of 0..520;
- {-------------Wymuszenie trybu 256 kolorow-------------}
- {$f+}
- function detectsvga256:integer;
- begin
- detectsvga256:=tryb;
- end;
- {$f-}
- {-------------Procedura startowa-----------------------}
- procedure start;
- var
- autodetect:pointer;
- ster:integer;
- begin
- tryb:=3;
- autodetect:=@detectsvga256;
- ster:=installuserdriver('svga256',autodetect);
- initgraph(ster,tryb,'');
- end;
- {-------------Program glowny -------------------------}
- Begin
- clrscr;
- randomize;
- repeat
- writeln('Podaj ilosc pomiarow(n od 5 do 20)');
- readln(n);
- if (n>20) or (n<5) then writeln('Zla wartosc, n musi miescic sie w przedzile <5,20>');
- until (n<=20) and (n>=5);
- repeat
- writeln('Podaj wartosc minimalna(ymin od -10000 do 10000)');
- readln(ymin);
- if (ymin>10000) and (ymin<-10000) then writeln('Zla wartosc, ymin musi miescic sie w przedzile <-10000,10000>');
- until (ymin<=10000) and (ymin>=-10000);
- repeat
- writeln('Podaj wartosc maksymalna(ymax od -10000 do 10000 i wieksza od ymin)');
- readln(ymax);
- if (ymax>10000) or (ymax<-10000) then
- writeln('Zla wartosc, ymax musi miescic sie w przedzile <-10000,10000>');
- until (ymax<=10000) and (ymax>=-10000);
- for i:=1 to n do
- tab[i]:=random(ymax-ymin)+ymin+1;
- clrscr;
- for i:=1 to n do
- writeln('tab[',i,']=',tab[i]);
- nn:=tab[1];
- nw:=tab[1];
- for i:=1 to n do
- begin
- if tab[i]<nn then nn:=tab[i];
- if tab[i]>nw then nw:=tab[i];
- end;
- writeln('Wartosc najwyzsza to ',nw,', a najnizsza to ',nn);
- if (nn<0) and (nw>0) then l:=round(nw/(nw+abs(nn))*520+40) else
- if nn>0 then l:=540 else l:=40;
- writeln('L to ',l);
- readln;
- start;
- setcolor(white);
- line(30,l,770,l);
- line(30,20,30,580);
- line(25,25,30,20);
- line(35,25,30,20);
- line(765,l-5,770,l);
- line(765,l+5,770,l);
- u:=740 div (2*n);
- tay[1]:=0;
- for i:=1 to n do
- tay[i]:=tay[i-1]+u;
- for i:=1 to n do
- taw[i]:=round(tay[i]/(nw+abs(nn))*520);
- for i:=1 to n do
- begin
- if tab[i]>=0 then
- bar3d(u+30,l-tay[i],2*u+30,l,10,topon);
- u:=u+u;
- if tab[i]<=0 then
- bar3d(u+30,l,2*u+30,l+tay[i],10,topon);
- end;
- readln;
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement