CLS RANDOMIZE TIMER INPUT "n = ", n DIM A(n, n) PRINT "1 - BBECTI ELEMENTbI C KLABbI" PRINT "2 - RANDOM" INPUT BBOD IF BBOD = 2 THEN FOR i = 1 TO n FOR j = 1 TO n A(i, j) = RND * 21 - 10 NEXT j NEXT i ELSE FOR i = 1 TO n FOR j = 1 TO n PRINT "A["; i; ","; j; "] = "; INPUT "", A(i, j) NEXT j NEXT i END IF CLS FOR i = 1 TO n FOR j = 1 TO n PRINT USING "###.##"; A(i, j); PRINT " "; NEXT j PRINT NEXT i C = 1 FOR i = 1 TO n FOR j = 1 TO n IF A(i, j) <> A(j, i) THEN C = 0 END IF NEXT j NEXT i IF C = 1 THEN PRINT "DA" ELSE PRINT "NET" END IF END
RANDOMIZE TIMER
INPUT "n = ", n
DIM A(n, n)
PRINT "1 - BBECTI ELEMENTbI C KLABbI"
PRINT "2 - RANDOM"
INPUT BBOD
IF BBOD = 2 THEN
FOR i = 1 TO n
FOR j = 1 TO n
A(i, j) = RND * 21 - 10
NEXT j
NEXT i
ELSE
FOR i = 1 TO n
FOR j = 1 TO n
PRINT "A["; i; ","; j; "] = ";
INPUT "", A(i, j)
NEXT j
NEXT i
END IF
CLS
FOR i = 1 TO n
FOR j = 1 TO n
PRINT USING "###.##"; A(i, j);
PRINT " ";
NEXT j
PRINT
NEXT i
C = 1
FOR i = 1 TO n
FOR j = 1 TO n
IF A(i, j) <> A(j, i) THEN
C = 0
END IF
NEXT j
NEXT i
IF C = 1 THEN
PRINT "DA"
ELSE
PRINT "NET"
END IF
END
// Внимание! Если программа не работает, обновите версию!
begin
var a:=ArrRandom(ReadInteger('n='),-50,50); a.Println;
a:=(a.Where(x->x<0)+a.Where(x->x>=0)).ToArray; a.Println;
Writeln('Номер максимального элемента: ',a.IndexMax+1);
Writeln('Среднее арифметическое нечетных по порядку: ',
a.Where((x,i)->i.IsEven).Average)
end.
Пример
n= 15
18 -24 31 -4 -13 -45 24 -25 34 -42 -6 36 -50 40 -15
-24 -4 -13 -45 -25 -42 -6 -50 -15 18 31 24 34 36 40
Номер максимального элемента: 15
Среднее арифметическое нечетных по порядку: 2.75