#include <iostream>
#include <time.h>
using namespace std;
double ssummaf(double array2[5][5], size_t m, size_t i, size_t j)
{
double s = 0;
for (size_t k = 0; k < m; k++)
s += array2[i][k] * array2[j][k];
return s;
}
bool proverka(double array1[5][5], size_t n, size_t m)
for (size_t i = 0; i < n; i++) {
size_t j = i;
s = ssummaf(array1, m, i, j);
if (s != 1)
return false;
for (size_t j = i + 1; j < n; j++) {
if (s != 0)
return true;
int main() {
srand(time(0));
setlocale(LC_ALL, "Russian");
double A[5][5], B[5][5], C[5][5];
double D[5][5]{ {1,0,0,0,0},{0,1,0,0,0},{0,0,1,0,0},{0,0,0,1,0},{0,0,0,0,1} };
for (size_t i = 0; i < 5; i++) {
for (size_t j = 0; j < 5; j++)
A[i][j] = rand() % 2;
B[i][j] = A[j][i];
cout << " " << A[i][j];
cout << endl;
cout << " " << B[i][j];
bool answer1 = proverka(A, 5, 5);
bool answer2 = proverka(D, 5, 5);
if (answer1)
cout << "Ортонормирована\n";
else
cout << "Не ортонормирована\n";
if (answer2)
return 3;
function IsOrtho(a: array[,] of integer): boolean;
begin
var n := a.RowCount - 1;
for var row1 := 0 to n do
for var row2 := 0 to n do
var s := 0;
for var col := 0 to n do
s += a[row1, col] * a[row2, col];
if (row1 = row2) and (s <> 1) then
IsOrtho := False;
Exit
end;
if (row1 <> row2) and (s <> 0) then
end
IsOrtho := True
var n := 5;
var a := ReadMatrInteger(n, n);
if IsOrtho(a) then
Println('Ортонормированная')
Println('Не ортонормированная')
end.
На pascalabc.net
#include <iostream>
#include <time.h>
using namespace std;
double ssummaf(double array2[5][5], size_t m, size_t i, size_t j)
{
double s = 0;
for (size_t k = 0; k < m; k++)
s += array2[i][k] * array2[j][k];
return s;
}
bool proverka(double array1[5][5], size_t n, size_t m)
{
double s = 0;
for (size_t i = 0; i < n; i++) {
size_t j = i;
s = ssummaf(array1, m, i, j);
if (s != 1)
return false;
for (size_t j = i + 1; j < n; j++) {
s = ssummaf(array1, m, i, j);
if (s != 0)
return false;
}
}
return true;
}
int main() {
srand(time(0));
setlocale(LC_ALL, "Russian");
double A[5][5], B[5][5], C[5][5];
double D[5][5]{ {1,0,0,0,0},{0,1,0,0,0},{0,0,1,0,0},{0,0,0,1,0},{0,0,0,0,1} };
for (size_t i = 0; i < 5; i++) {
for (size_t j = 0; j < 5; j++)
A[i][j] = rand() % 2;
}
for (size_t i = 0; i < 5; i++) {
for (size_t j = 0; j < 5; j++)
B[i][j] = A[j][i];
}
for (size_t i = 0; i < 5; i++) {
for (size_t j = 0; j < 5; j++)
cout << " " << A[i][j];
cout << endl;
}
cout << endl;
for (size_t i = 0; i < 5; i++) {
for (size_t j = 0; j < 5; j++)
cout << " " << B[i][j];
cout << endl;
}
bool answer1 = proverka(A, 5, 5);
bool answer2 = proverka(D, 5, 5);
if (answer1)
cout << "Ортонормирована\n";
else
cout << "Не ортонормирована\n";
if (answer2)
cout << "Ортонормирована\n";
else
cout << "Не ортонормирована\n";
return 3;
}
function IsOrtho(a: array[,] of integer): boolean;
begin
var n := a.RowCount - 1;
for var row1 := 0 to n do
for var row2 := 0 to n do
begin
var s := 0;
for var col := 0 to n do
s += a[row1, col] * a[row2, col];
if (row1 = row2) and (s <> 1) then
begin
IsOrtho := False;
Exit
end;
if (row1 <> row2) and (s <> 0) then
begin
IsOrtho := False;
Exit
end
end;
IsOrtho := True
end;
begin
var n := 5;
var a := ReadMatrInteger(n, n);
if IsOrtho(a) then
Println('Ортонормированная')
else
Println('Не ортонормированная')
end.
На pascalabc.net