Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>//для случайных чисел
- using namespace std;
- int main()
- {
- srand(time(NULL));//для случайных чисел
- setlocale(LC_ALL, "ru");
- const int SIZE = 5;
- int arr[SIZE][SIZE];//поганный массив
- for (int i = 0; i < SIZE; i++)
- {
- for (int j = 0; j < SIZE; j++)
- {
- if (i == j)
- arr[i][j] = 0;
- else
- arr[i][j] = rand() % 2;//случайные числа от 0 до 2(не включительно или же до 1 включительно)
- }
- }
- for (int i = 0; i < SIZE; i++)//цикл для вывода массива
- {
- for (int j = 0; j < SIZE; j++)
- {
- cout << arr[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- bool var = false;
- for (int i = 0; i < SIZE; i++)
- {
- int counter = 0;
- for (int j = 0; j < SIZE; j++)
- {
- if (i != j)
- {
- if (arr[i][j] == 1)
- counter++;
- }
- }
- if (counter == SIZE - 1)
- {
- cout << "номер строки с 1 = " << i + 1 << endl;
- var = true;
- }
- }
- if (!var)
- cout << "Нет таких строк " << endl;
- var = false;
- for (int j = 0; j < SIZE; j++)
- {
- int counter = 0;
- for (int i = 0; i < SIZE; i++)
- {
- if (i != j)
- {
- if (arr[i][j] == 0)
- counter++;
- }
- }
- if (counter == SIZE - 1)
- {
- cout << "номер столбца с 0 = " << j + 1 << endl;
- var = true;
- }
- }
- if(!var)
- cout << "Нет таких столбцов "<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement