Answer the question
In order to leave comments, you need to log in
A simple C++ program doesn't work correctly. How to fix?
As planned, the program should take the row number in a double square array and compare the row with the column with the corresponding number, but something went wrong.
#include <iostream>
using namespace std;
int main() {
const int n = 1000;
int a,b, i, j;
bool str= false;
float arr[n][n];
cout << "Введите размерность:\n";
cin >> a;
cout << "Заполнение массива:\n";
for (int i = 0; i < a; i++) {
for (int j = 0; j < a; j++) {
cout <<"Введите элемент ["<<i+1<<","<<j+1<<"]:";
cin >> arr[i][j];
}
}
for (int i = 0; i < a; i++) {
for (int j = 0; j < a; j++)
cout << arr[i][j]<<" ";
cout << "\n";
}
cout << "Введите номер строки: \n";
cin >> b;
for (int i = 0; i < a; i++) {
for (int j = 0; j < a; j++)
if (arr[b-1][j] == arr[i][b-1]) str = true;
}
if (str == false) cout <<"Строка и столбец не совпадают";
if (str == true) cout <<"Строка и столбец совпадают";
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question