Advertisement
labyyysosaaat

Untitled

Sep 29th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. setlocale(LC_ALL, "Russian");
  6. int rows=20;
  7. int cols=20;
  8. cout << "Введите количество строк: ";
  9. cin >> rows;
  10. cout << "Введите количество столбцов: ";
  11. cin >> cols;
  12. if (int(rows) <=0 || int(cols) <=0 )
  13. {
  14. cout << "Введены неверные значение" << endl;
  15. return 0;
  16. }
  17.  
  18. if (int(rows) != int(cols)) {
  19. cout << "Не квадратная матрица" << endl;
  20. return 0;
  21. }
  22. int **arr = new int*[rows];
  23. for (int i = 0; i < rows; i++) {
  24. arr[i] = new int[cols];
  25. }
  26. for (int i = 0; i < rows; i++) {
  27.  
  28. for (int j = 0; j < cols; j++) {
  29. cout << "строка # "<< i+1 << "\t";
  30. cout << "столбец # "<<j+1 << "= ";
  31. cin >> arr[i][j];
  32.  
  33. }
  34. }
  35. for (int i = 0; i < rows; i++) {
  36. for (int j = 0; j < cols; j++) {
  37. cout << arr[i][j] << "\t";
  38.  
  39. }
  40. cout << endl;
  41. }
  42. for (int i = 0; i < rows; ++i)
  43. {
  44. int max = 0;
  45. for (int j = 0; j < cols; ++j)
  46. {
  47. if ((arr[j][i] > arr[j + 1][i]) && (arr[j][i] > max));
  48. }
  49. cout << "В " << i + 1 << " столбце макс. элемент " << max << endl;
  50.  
  51. }
  52. for (int i = 0; i < rows; i++)
  53. {
  54. delete[] arr[i];
  55. }
  56. delete[] arr;
  57. return 0;
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement