DECLARE SUB SYMMA ( )
DECLARE FUNKTION SREDZNA4! ( )
CLS
DIM SHARED I%, N%, J%, K%, S!, SCP!, Z!
INPUT "ENTER KOL-VO STROK STOLBCOV"; N%
DIM SHARED Z!(1 TO N%, 1 TO N%)
FOR I% = 1 TO N%: FOR J% = 1 TO N%
PRINT "Z("; I%; ", "; J%; ")"
INPUT " ", Z(I%, J%)
NEXT J%: NEXT I%
CALL SYMMA
SCP! = SREDZNA4!
PRINT "SYMMA OTRICATELNIH EL-OV NIGE GLAVN DIAG"; S!
PRINT "SREDNEE ZNA4ENIE POLOG EL-OV NA GLAVN DIAG"; SCP!
END
SUB SYMMA
S! = 0
FOR I% = 1 TO N%: FOR J% = 1 TO N%
IF (I% > J%) AND (Z!(I%, J%) < 0) THEN
S! = S! + Z!(I%, J%)
END IF
NEXT J%: NEXT I%
END SUB
FUNCTION SREDZNA4!
K% = 0
SCP! = 0
FOR I% = 1 TO N%: FOR J% = 1 TO N%
IF (I% = J%) AND (Z!(I%, J%) > 0) THEN
SCP! = SCP! + Z!(I%, J%)
K% = K% + 1
END IF
NEXT J%, I%
SREDZNA4! = SCP! / K%
END FUNCTION
Тестирование выполнено в программе QB64 ( Скачать )