const n = 8, m = 8; var A: array[1..n,1..m] of integer; i, j, sum, product: integer; isnotnull: boolean; begin randomize; writeln('Случайная матрица:'); for i:=1 to n do begin for j:=1 to m do begin A[i,j] := random(51) - 25; write(A[i,j]:5); end; writeln; end; sum := 0; for i:=1 to n do if A[i,n-i+1] < 0 then sum := sum + A[i,n-i+1]; writeln('Сумма отрицательных элементов побочной диагонали = ', sum); product := 1; isnotnull := False; for i:=1 to n-1 do for j:=2 to n do if (j > i) and (A[i,j] <> 0) then begin isnotnull := True; product := product * A[i,j]; end; if isnotnull writeln('Произведение ненулевых элементов в области выше главной диагонали = ', product) else writeln('Ненулевых элементов в области выше главной диагонали нет.', product); readln; end.
В Бейсике есть встроенная функция ATN - арктангенс, поэтому угол можно в градусах посчитать.
DIM a, b, c, cs, cst, ang, PI INPUT " a = ", a INPUT " b = ", b INPUT " c = ", c PRINT PI = 3.141593 cs = (b * b + c * c - a * a) / (2 * b * c) cst = cs IF cs < 0 THEN cst = SQR(1 - cs * cs) ang = ATN(SQR(1 - cst * cst) / cst) * 360 / (2 * PI) IF cs < 0 THEN ang = ang + 90 PRINT "угол A = ", PRINT USING "###.##"; ang cs = (a * a + c * c - b * b) / (2 * a * c) cst = cs IF cs < 0 THEN cst = SQR(1 - cs * cs) ang = ATN(SQR(1 - cst * cst) / cst) * 360 / (2 * PI) IF cs < 0 THEN ang = ang + 90 PRINT "угол B = ", PRINT USING "###.##"; ang cs = (a * a + b * b - c * c) / (2 * a * b) cst = cs IF cs < 0 THEN cst = SQR(1 - cs * cs) ang = ATN(SQR(1 - cst * cst) / cst) * 360 / (2 * PI) IF cs < 0 THEN ang = ang + 90 PRINT "угол C = ", PRINT USING "###.##"; ang PRINT "Выход - любая клавиша ... " DO LOOP WHILE INKEY$ = ""
что-то типа этого:
const n = 8, m = 8;
var
A: array[1..n,1..m] of integer;
i, j, sum, product: integer;
isnotnull: boolean;
begin
randomize;
writeln('Случайная матрица:'); for i:=1 to n do begin
for j:=1 to m do begin
A[i,j] := random(51) - 25;
write(A[i,j]:5);
end;
writeln;
end; sum := 0;
for i:=1 to n do
if A[i,n-i+1] < 0 then
sum := sum + A[i,n-i+1];
writeln('Сумма отрицательных элементов побочной диагонали = ', sum); product := 1;
isnotnull := False;
for i:=1 to n-1 do
for j:=2 to n do
if (j > i) and (A[i,j] <> 0) then begin
isnotnull := True;
product := product * A[i,j];
end;
if isnotnull
writeln('Произведение ненулевых элементов в области выше главной диагонали = ', product)
else
writeln('Ненулевых элементов в области выше главной диагонали нет.', product); readln;
end.
поэтому угол можно в градусах посчитать.
DIM a, b, c, cs, cst, ang, PI
INPUT " a = ", a
INPUT " b = ", b
INPUT " c = ", c
PRINT
PI = 3.141593
cs = (b * b + c * c - a * a) / (2 * b * c)
cst = cs
IF cs < 0 THEN cst = SQR(1 - cs * cs)
ang = ATN(SQR(1 - cst * cst) / cst) * 360 / (2 * PI)
IF cs < 0 THEN ang = ang + 90
PRINT "угол A = ",
PRINT USING "###.##"; ang
cs = (a * a + c * c - b * b) / (2 * a * c)
cst = cs
IF cs < 0 THEN cst = SQR(1 - cs * cs)
ang = ATN(SQR(1 - cst * cst) / cst) * 360 / (2 * PI)
IF cs < 0 THEN ang = ang + 90
PRINT "угол B = ",
PRINT USING "###.##"; ang
cs = (a * a + b * b - c * c) / (2 * a * b)
cst = cs
IF cs < 0 THEN cst = SQR(1 - cs * cs)
ang = ATN(SQR(1 - cst * cst) / cst) * 360 / (2 * PI)
IF cs < 0 THEN ang = ang + 90
PRINT "угол C = ",
PRINT USING "###.##"; ang
PRINT "Выход - любая клавиша ... "
DO
LOOP WHILE INKEY$ = ""