В массиве А(10,10) найти столбец с минимальной суммой элементов — QBasic(Бейсик)

CLS
RANDOMIZE TIMER
CONST kolStrk = 10
CONST kolStlb = 10
DIM A(kolStrk, kolStlb) AS INTEGER, sum AS INTEGER
DIM numCol AS STRING
 
min = 0: numCol = ""
 
FOR i = 1 TO kolStrk
    FOR j = 1 TO kolStlb
        A(i, j) = FIX(RND / 0.1)
    NEXT j
    min = min + A(i, 1)
NEXT i
 
PRINT "Summa 1 Stolbca: "; min
 
FOR j = 1 + 1 TO kolStlb - 1
    summ = 0
    FOR i = 1 TO kolStrk
        summ = summ + A(i, j)
    NEXT i
    IF summ < min THEN min = summ
    PRINT "Summa"; j; "Stolbca: "; summ
NEXT j
 
FOR j = 1 TO kolStlb
    summ = 0
    FOR i = 1 TO kolStrk
        summ = summ + A(i, j)
    NEXT i
    IF summ = min THEN numCol = numCol + "#" + STR$(j) + " "
NEXT j
PRINT
PRINT
PRINT "Stolbec(ci): "; numCol; " Imeyet(yut) Naimenshuyu Summu ="; min
cls
dim a(10, 10)
for i =1 to 10
for j = 1 to 10
cls
? "a(";i;",";j;")=";
input a(i,j)
next j
next i
min = 1e+38
for i = 1 to 10
s = 0
for j = 1 to 10
s= s +a(i,J)
next j
if min> s then min = s: k= k= i
next i
for i= 1 to 10
for j = 1 to 10
if i= k then ? a(i,j), 12 else ? a(i,j);
next j
?
next i

Тестирование выполнено в программе QB64 ( Скачать )

Leave a Comment