Advertisement
Guest User

proga

a guest
Jun 3rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>//для случайных чисел
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. srand(time(NULL));//для случайных чисел
  8. setlocale(LC_ALL, "ru");
  9. const int SIZE = 5;
  10. int arr[SIZE][SIZE];//поганный массив
  11. for (int i = 0; i < SIZE; i++)
  12. {
  13. for (int j = 0; j < SIZE; j++)
  14. {
  15. if (i == j)
  16. arr[i][j] = 0;
  17. else
  18. arr[i][j] = rand() % 2;//случайные числа от 0 до 2(не включительно или же до 1 включительно)
  19. }
  20. }
  21. for (int i = 0; i < SIZE; i++)//цикл для вывода массива
  22. {
  23. for (int j = 0; j < SIZE; j++)
  24. {
  25. cout << arr[i][j] << " ";
  26. }
  27. cout << endl;
  28. }
  29. cout << endl;
  30. bool var = false;
  31. for (int i = 0; i < SIZE; i++)
  32. {
  33. int counter = 0;
  34. for (int j = 0; j < SIZE; j++)
  35. {
  36. if (i != j)
  37. {
  38. if (arr[i][j] == 1)
  39. counter++;
  40. }
  41.  
  42. }
  43. if (counter == SIZE - 1)
  44. {
  45. cout << "номер строки с 1 = " << i + 1 << endl;
  46. var = true;
  47. }
  48. }
  49. if (!var)
  50. cout << "Нет таких строк " << endl;
  51. var = false;
  52. for (int j = 0; j < SIZE; j++)
  53. {
  54. int counter = 0;
  55. for (int i = 0; i < SIZE; i++)
  56. {
  57. if (i != j)
  58. {
  59. if (arr[i][j] == 0)
  60. counter++;
  61. }
  62.  
  63. }
  64. if (counter == SIZE - 1)
  65. {
  66. cout << "номер столбца с 0 = " << j + 1 << endl;
  67. var = true;
  68. }
  69. }
  70. if(!var)
  71. cout << "Нет таких столбцов "<<endl;
  72. system("pause");
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement