Answer the question
In order to leave comments, you need to log in
The symmetry of the array about the main diagonal. What's wrong?
Array arr[i][j] with real numbers.
a and b are dimensions.
//проверяем симметрию//
cout << "\n";
//переменная-показатель симметрии//
sim= true;
//прогоняем массив//
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b;j++)
{
//если зеркальные значения не равны sim становится ложным //
if (i=j) break;
if (arr[i][j] != arr[j][i])
{
sim = false;
break;
}
if (sim=false) break;
}
}
//выводим ответ//
if (sim=true)
cout<<"Массив симметричен"<<endl;
if (sim=false)
cout<<"Массив несимметричен"<<endl;
Answer the question
In order to leave comments, you need to log in
What's wrong:
1. The if(a=b) expression must be replaced with if(a==b)
2. Real numbers a and b are equal if fabs(a - b) < EPSILON. Therefore, the expression if(a!=b) must be replaced with if(!(fabs(a - b) < EPSILON))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question