REM Определение количества разных элементов в массиве
DECLARE SUB SORT (A() AS INTEGER, N%)
DECLARE FUNCTION DIFFERENCE% (A() AS INTEGER, N%)
DEFINT A-Z
DIM A(5)
DATA 0,0,0,0,0
DATA 1,1,1,1,1
DATA 0,1,1,1,1
DATA 0,0,1,1,2
DATA 0,1,2,3,4
DATA 1,2,3,4,5
CLS
FOR k = 1 TO 5
FOR I = 0 TO 4: READ A(I): NEXT I
PRINT "Количество разных чисел в массиве "; k; " = ";
PRINT DIFFERENCE(A(), 5)
NEXT k
END
FUNCTION DIFFERENCE (A() AS INTEGER, N%)
SORT A(), N%
M = 1
FOR I = 0 TO N% - 2
IF A(I) <> A(I + 1) THEN M = M + 1
NEXT I
DIFFERENCE = M
END FUNCTION
SUB SORT (A() AS INTEGER, N%)
REM тело любой процедуры сортировки
END SUB