Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cmath>
  4. #include<ctime>
  5. using namespace std;
  6. int main()
  7. {
  8.  
  9. setlocale(LC_ALL, "Russian");
  10. srand((unsigned)time(NULL));
  11.  
  12. int l, r, s = 0;
  13. cout << "Введите кол-во линий = ";
  14. cin >> l;
  15. cout << "Введите кол-во столбцов = ";
  16. cin >> r;
  17.  
  18. if (l > 20 || r > 20 || r < 1 || l < 1)
  19. {
  20. return 1;
  21. }
  22. int** arr;
  23. arr = new int* [l];
  24. for (int i = 0; i < l; i++)
  25. arr[i] = new int[r];
  26. cout << "Введите " << l * r << " элементов матрицы: ";
  27. for (int i = 0; i < l; i++)
  28. {
  29. for (int j = 0; j < r; j++)
  30. {
  31. cin >> arr[i][j];
  32. }
  33. }
  34. cout << "Элементы массива: " << endl;
  35. for (int i = 0; i < l; i++)
  36. {
  37. for (int j = 0; j < r; j++)
  38. {
  39. cout << arr[i][j] << " ";
  40. }
  41.  
  42. cout << endl;
  43. }
  44. cout << endl << endl << endl;
  45. for (int i = 0; i < l; i++)
  46. {
  47. for (int j = 0; j < r; j++)
  48. {
  49.  
  50. if (arr[i][j] == 0)
  51.  
  52. s++;
  53. }
  54. if (s == 1)
  55. {
  56. cout << endl << i + 1 << "-ая " << "строка содержит единственный нуль" << endl;
  57. s = 0;
  58. }
  59. else
  60. cout << i + 1 << "-ая " << "строка содержит больше 1 нуля, либо не содержит их вовсе!" << endl;
  61. }
  62. cout << endl << endl << endl;
  63. for (int i = 0; i < l; i++)
  64. {
  65. for (int j = 0; j < r; j++)
  66. {
  67. if (arr[j][i] == 0)
  68.  
  69. s++;
  70. }
  71. if (s == 1)
  72. {
  73. cout << endl << i + 1 << "-й " << "столбец содержит единственный нуль" << endl;
  74. s = 0;
  75. }
  76. else
  77. cout << i + 1 << "-й " << "столбец содержит больше 1 нуля, либо не содержит их вовсе!" << endl;
  78. }
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement