|
|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 1152 (0x480)
Types: TextFile
Names: »MAXPUNKT.PAS«
└─⟦08ea08c61⟧ Bits:30003924 PolyPascal programmer
└─⟦this⟧ »MAXPUNKT.PAS«
└─⟦09235ab48⟧ Bits:30003065 Demoprogrammer K-Z til Pascal bog
└─⟦this⟧ »MAXPUNKT.PAS«
└─⟦092727b26⟧ Bits:30005927 Demoprogrammer til Pascal bog (Jet-80)
└─⟦this⟧ »MAXPUNKT.PAS«
PROGRAM maxpunkt;
VAR
a, b, byt, x, fx, fmax, xmax, delta : REAL;
i, antal : INTEGER;
FUNCTION f(x : REAL) : REAL;
BEGIN
f := ((x - 3) * x - 9) * x + 2;
END;
BEGIN
WRITE(CLRHOM);
WRITE('Tast a i intervallet (a,b): '); READLN(a);
WRITE('Tast b i intervallet (a,b): '); READLN(b);
WRITE('Hvor mange delintervaller skal (a,b) deles op i: ');
READLN(antal);
IF a > b
THEN
BEGIN
byt := a;
a := b;
b := byt;
END;
delta := (b - a) / antal;
fmax := f(a);
xmax := a;
x := a;
FOR i := 1 TO antal DO
BEGIN
x := x + delta;
fx := f(x);
IF fx > fmax
THEN
BEGIN
fmax := fx;
xmax := x;
END;
END;
WRITELN('Maximumsværdien for funktionen i (', a : 6 : 2 , ',',
b : 6 : 2, ')');
WRITELN('baseret på ', antal + 1, ' støttepunkter: ', fmax : 10 : 4);
WRITELN('Maximumspunktet er: ', xmax : 6 : 2);
END.
«eof»