1. VBA с выводом массива на лист рабочей книги Sub Prog() Dim i As Integer, n As Integer, max As Integer, R As Range Cells.Clear Randomize Timer n = InputBox("Введите размер массива") ReDim a(1 To n, 1 To 1) As Integer For i = 1 To n a(i, 1) = Int(50 * Rnd - 25) Next i Set R = Range(Cells(1, 1), Cells(n, 1)) R = a MsgBox "Минимум " + Str(Application.WorksheetFunction.Min(R)) End Sub
Файл формата MS Excel 2003 находится во вложении.
2. Программа на Microsoft QBasic DIM i AS INTEGER, n AS INTEGER, max AS INTEGER CLS RANDOMIZE TIMER INPUT "Введите размер массива: ", n REDIM a(1 TO n) AS INTEGER min = 1000 FOR i = 1 TO n a(i) = INT(50 * RND - 25) PRINT a(i); " "; IF a(i) < min THEN min = a(i) NEXT i PRINT PRINT "Минимум "; min
Sub Prog()
Dim i As Integer, n As Integer, max As Integer, R As Range
Cells.Clear
Randomize Timer
n = InputBox("Введите размер массива")
ReDim a(1 To n, 1 To 1) As Integer
For i = 1 To n
a(i, 1) = Int(50 * Rnd - 25)
Next i
Set R = Range(Cells(1, 1), Cells(n, 1))
R = a
MsgBox "Минимум " + Str(Application.WorksheetFunction.Min(R))
End Sub
Файл формата MS Excel 2003 находится во вложении.
2. Программа на Microsoft QBasic
DIM i AS INTEGER, n AS INTEGER, max AS INTEGER
CLS
RANDOMIZE TIMER
INPUT "Введите размер массива: ", n
REDIM a(1 TO n) AS INTEGER
min = 1000
FOR i = 1 TO n
a(i) = INT(50 * RND - 25)
PRINT a(i); " ";
IF a(i) < min THEN min = a(i)
NEXT i
PRINT
PRINT "Минимум "; min
Тестовое решение:
Введите размер массива: 15
-8 5 -11 -11 19 -10 7 -12 -20 -9 7 -14 -1 10 -9
Минимум -20