' QBASIC CONST n = 10 DIM a(1 TO n) AS DOUBLE, b(1 TO n) AS DOUBLE, x(1 TO n) AS DOUBLE RANDOMIZE TIMER CLS FOR i = 1 TO n a(i) = 50 * RND - 25 b(i) = 50 * RND - 25 IF a(i) <> 0 THEN x(i) = b(i) / a(i) ELSE x(i) = 0 END IF PRINT USING "###."; a(i); PRINT " * "; PRINT USING "###."; x(i); PRINT " = "; PRINT USING "###."; b(i) NEXT i
Var A,B: array [1..10,1..10] of integer; i, j, n: integer; begin Randomize;writeln('Введите размерность n');readln(n);writeln('Матрица А'); for i:=1 to n do begin for j:=1 to n do begin A[i,j]:= random(10)+1;write(A[i,j]:3);end;writeln;end; writeln('Матрица B'); for i:=1 to n do begin for j:=1 to n do begin B[i,j]:= random(10)+2;write(B[i,j]:3);end;writeln;end; writeln('ответ: матрица AB'); for i:=1 to n do for j:=1 to n do begin C[i,j]:=(A[i,j]*B[i,j]);end;writeln; for i:=1 to n do begin for j:=1 to n do begin write(C[i,j]:3);end; writeln;end; writeln('ответ :матрица ВА'); for i:=1 to n do for j:=1 to n do begin D[i,j]:=(B[i,j]*A[i,j]);end; for i:=1 to n do begin for j:=1 to n do begin write(D[i,j]:3);end; writeln;end; end.
CONST n = 10
DIM a(1 TO n) AS DOUBLE, b(1 TO n) AS DOUBLE, x(1 TO n) AS DOUBLE
RANDOMIZE TIMER
CLS
FOR i = 1 TO n
a(i) = 50 * RND - 25
b(i) = 50 * RND - 25
IF a(i) <> 0 THEN
x(i) = b(i) / a(i)
ELSE
x(i) = 0
END IF
PRINT USING "###."; a(i);
PRINT " * ";
PRINT USING "###."; x(i);
PRINT " = ";
PRINT USING "###."; b(i)
NEXT i
Тестовое решение:
-14.65854 * 0.53867 = -7.89606
-14.19729 * 1.08311 = -15.37722
-17.21156 * -0.07488 = 1.28888
16.17024 * -1.09750 = -17.74690
-13.80126 * -1.06180 = 14.65417
17.78583 * 0.83055 = 14.77207
-10.95534 * -1.58899 = 17.40791
-11.84992 * 1.66222 = -19.69714
-24.91831 * -0.95948 = 23.90864
-12.68757 * 0.84160 = -10.67785
i, j, n: integer;
begin
Randomize;writeln('Введите размерность n');readln(n);writeln('Матрица А');
for i:=1 to n do begin
for j:=1 to n do begin
A[i,j]:= random(10)+1;write(A[i,j]:3);end;writeln;end;
writeln('Матрица B');
for i:=1 to n do begin
for j:=1 to n do begin
B[i,j]:= random(10)+2;write(B[i,j]:3);end;writeln;end;
writeln('ответ: матрица AB');
for i:=1 to n do
for j:=1 to n do begin C[i,j]:=(A[i,j]*B[i,j]);end;writeln;
for i:=1 to n do begin
for j:=1 to n do begin
write(C[i,j]:3);end; writeln;end;
writeln('ответ :матрица ВА');
for i:=1 to n do
for j:=1 to n do begin D[i,j]:=(B[i,j]*A[i,j]);end;
for i:=1 to n do begin
for j:=1 to n do begin
write(D[i,j]:3);end; writeln;end;
end.