    CLS
    DIM n(24), ntot(24)
    REM INPUT "Nome del file ELENCO: "; elenco$
    OPEN "elenco.txt" FOR INPUT AS #2
    REM INPUT "Nome del file FINALE: "; imptot$
    OPEN "imptot.txt" FOR OUTPUT AS #3
    REM INPUT "Nome del file IMPEGNO: "; impegno$
40  OPEN "impegno.txt" FOR INPUT AS #1
50  IF EOF(2) THEN GOTO 200
    INPUT #2, nome2$, tariffa
    REM prinT "leggo elenco:", nome2$
    FOR i = 1 TO 24: ntot(i) = 0: NEXT i
60  IF EOF(1) THEN GOTO 100
    INPUT #1, nome1$
    REM PRINT "leggo impegno:"; nome1$
    FOR i = 1 TO 24
    INPUT #1, n(i)
    NEXT i
    IF nome1$ <> nome2$ THEN 60
    FOR i = 1 TO 24
    ntot(i) = ntot(i) + n(i)
    NEXT i
    GOTO 60
100 PRINT nome2$ + ","; : FOR i = 1 TO 23: PRINT ntot(i); : PRINT ","; : NEXT i: PRINT ntot(24)
    PRINT #3, nome2$ + ","; : FOR i = 1 TO 23: PRINT #3, ntot(i); : PRINT #3, ","; : NEXT i: PRINT #3, ntot(24)
    CLOSE 1
    GOTO 40
200 CLOSE #1: CLOSE #2: CLOSE #3
    END



