program grafi;
uses
crt, graph;
var
datos : array[1..6] of real;
drive, modo : integer;
tt, x, y, i : integer;
tecla : char;
temp : real;
procedure entradas;
var
dat : string[6];
ra : real;
err : integer;
begin
i := 1;
gotoxy(10,10);write('Entre N : ');
gotoxy(19,10);clreol;
repeat
tecla := readkey;
if tecla in[#48..#57,#46] then
begin
dat[i] := tecla;
dat[0] := chr(i);
gotoxy(18 + i,10);write(dat[i]);
i := i + 1;
if i > 6 then
i := 6;
end;
if tecla = #8 then
begin
i := i - 1;
if i < 1 then
i := 1;
dat[i] := ' ';
dat[0] := chr(i);
gotoxy(18 + i,10);write(dat[i]);
end;
until tecla = #13;
if i > 1 then
begin
val(dat,ra,err);
datos[tt] := ra;
end;
end;
begin
clrscr;
for tt := 1 to 6 do
begin
entradas;
end;
clrscr;
gotoxy(10,10);write('Presentacion Ordenada o Normal [O/N]');
repeat
tecla := upcase(readkey);
until tecla in[#79,#78];
if tecla = #79 then
begin
temp := 0;
for i := 1 to 6 do
begin
for tt := 1 to 6 do
begin
if datos[i] < datos[tt] then
begin
temp := datos[tt];
datos[tt] := datos[i];
datos[i] := temp;
end;
temp := 0;
end;
end;
end;
clrscr;
drive := detect;
initgraph(drive,modo,'C: pgi'); {Fijate en esto C: pgi ponlo como lo tengas tu}
if graphresult <> 0 then
halt(1);
setcolor(15);
x := 10;
outtextxy((getmaxx div 2) - 40,(getmaxy div 2) + 20,'Grafico de Barras');
for i := 1 to 6 do
begin
bar(((getmaxx div 2)- 36) + i + x,getmaxy div 2,
((getmaxx div 2) - 36) + (i + x) + 10,
(getmaxy div 2) - trunc(datos[i]));
x := x + 12;
end;
readln;
closegraph;
end.
|