program Tabula;
const
ColIstogramma = 70;
var
inferiore,
superiore,
passo,
min,
max : real;
function F (x : real) : real;
begin
F := 3.0 * x * x - 4.0 * x + 5.0
end;
procedure Tabulazione (inf, sup, passo : real);
var
x : real;
j : integer;
begin
x := inf;
writeln('x':8, 'F(x)':10);
for j := 0 to trunc((sup - inf) / passo) do
begin
writeln(x:8:3, F(x):10:3);
x := x + passo
end
end;
function Massimo (inf, sup, passo : real) : real;
var
x : real;
j : integer;
max,
valore : real;
begin
x := inf;
max := F(inf);
for j := 0 to trunc((sup - inf) / passo) do
begin
valore := F(x);
if valore > max then
max := valore;
x := x + passo
end;
Massimo := max
end;
function Minimo (inf, sup, passo : real) : real;
var
x : real;
j : integer;
min,
valore : real;
begin
x := inf;
min := F(inf);
for j := 0 to trunc((sup - inf) / passo) do
begin
valore := F(x);
if valore < min then
min := valore;
x := x + passo
end;
Minimo := min
end;
procedure Istogramma (inf, sup, passo, minimo, massimo : real);
var
x,
val : real;
j, k : integer;
begin
x := inf;
writeln(minimo:12:3, massimo:67:3);
for j := 0 to trunc((sup - inf) / passo) do
begin
val := F(x);
write(x:8:3, ' ');
for k := 1 to round((val-minimo)*ColIstogramma / (massimo-minimo)) do
write('*');
x := x + passo;
writeln
end
end;
begin
writeln('Estremo inferiore, estremo superiore e passo della funzione ?');
readln(inferiore, superiore, passo);
writeln;
writeln('TABULAZIONE DELLA FUNZIONE:');
Tabulazione(inferiore, superiore, passo);
writeln;
min := Minimo(inferiore, superiore, passo);
writeln('Minimo: ', min:8:4);
max := Massimo(inferiore, superiore, passo);
writeln('Massimo: ', max:8:4);
writeln;
writeln('ISTOGRAMMA DELLA FUNZIONE:');
Istogramma(inferiore, superiore, passo, min, max)
end.