CLS: PRINT "Vvedite kolichestvo"
INPUT " Stolbcov:", n
INPUT " Strok:", k
DIM L(n, k) AS INTEGER, hor, hs, hn, ver, vs, vn, dia, ds, dn
IF n < 2 THEN PRINT "malo stolbcov! Vihod!": END
IF k < 2 THEN PRINT "malo strok! Vihod!": END
'Zapolnim matricu
RANDOMIZE TIMER: PRINT: COLOR 14
FOR iy = 1 TO k: LOCATE , 3: FOR ix = 1 TO n
L(ix, iy) = INT(RND * 2)
PRINT STR$(L(ix, iy));
NEXT: PRINT: NEXT: COLOR 7
'ishem po gorizontali
FOR iy = 1 TO k: hs = 0: FOR ix = 1 TO n
IF L(ix, iy) = 0 THEN
hs = hs + 1
IF hs > hor THEN hor = hs: hn = iy
ELSE: hs = 0
END IF
NEXT: NEXT
'ishem po verticali
FOR ix = 1 TO n: vs = 0: FOR iy = 1 TO k
IF L(ix, iy) = 0 THEN
vs = vs + 1
IF vs > ver THEN ver = vs: vn = ix
ELSE: vs = 0
END IF
NEXT: NEXT
'ishem po diagonali
' . . .
'
PRINT CHR$(13) + "max chislo nulej po gorizontali:"; hor; "stroka:"; hn
PRINT "max chislo nulej po verticali:"; ver; "stolbec:"; vn
Тестирование выполнено в программе QB64 ( Скачать )