' -> Matematica e Calcolatore, sch.4, paragraf.1 DECLARE SUB Segno (x#, s#) CLS DEFDBL A-Z PRINT "La funzione e' da definire nel SUB Segno - vedi menu View" PRINT "Scegli un intervallo [a,b] in cui cada x tale che f(x)=0" Via: INPUT ; "a=", a: INPUT " b=", b Segno a, s1: Segno b, s2 IF NOT s1 = -s2 THEN PRINT "f(a) e f(b) devono avere segni opposti": GOTO Via PRINT "batti 'f' per finire, solo 'a capo' per continuare" x1 = a: x2 = b PRINT "x1"; TAB(20); "x2" Ciclo: h = x2 - x1: x = x1 + h / 2: Segno x, s IF s = s1 THEN x1 = x ELSE x2 = x PRINT x1; TAB(20); x2, : INPUT "", a$: IF a$ = "f" THEN END GOTO Ciclo 'questo Sub mette in S il segno di f(x), definita in y = ... SUB Segno (x, s) y = x + 10 - x * x s = SGN(y) END SUB