1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | DIM a( 20 ) RANDOMIZE TIMER n = 20 FOR i = 1 TO n a(i) = INT(RND * 21 - 10 ) NEXT i so = 0 : sp = 0 ko = 0 : kp = 0 FOR i = 1 TO n SELECT CASE SGN(a(i)) CASE - 1 : ko = ko + 1 : so = so + a(i) CASE 1 : kp = kp + 1 : sp = sp + a(i) END SELECT NEXT i CLS PRINT "kol-vo pol:"; kp, "summa pol:"; sp PRINT "kol-vo otr:"; ko, "summa otr:"; so |
Тестирование выполнено в программе QB64 ( Скачать )