INPUT "vvedite razmer massiva N=", n
DIM a(n)
RANDOMIZE TIMER
FOR i = 1 TO n
a(i) = INT(RND * 10)
NEXT
PRINT "massiv"
FOR i = 1 TO n
PRINT a(i);
NEXT
PRINT
INPUT "vvedite chislo k<N ", k
FOR i = n - k + 1 TO n
s = s + a(i)
NEXT
PRINT "summa="; s
Тестирование выполнено в программе QB64 ( Скачать )