Vla_DOS

Untitled

Feb 17th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include<time.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     setlocale(0, "");
  9.    
  10.     const int n = 4; //количество столбцов
  11.     int matr [n][n]; //исходная матрица
  12.     cout << "\nИсходная матрица:\n";
  13.  
  14.     //заполним матрицу случайными числами и выведем ее на дисплей
  15.     for (int i = 0; i < n; i++)
  16.     {
  17.         for (int j = 0; j < n; j++)
  18.         {
  19.             matr[i][j] = rand() - 500 % 5;
  20.             cout << matr[i][j] << "\t";
  21.         }
  22.         cout << endl;
  23.     }
  24.    
  25.     int mas[n];
  26.     size_t LengthOfArray = sizeof mas / sizeof mas[0];
  27.  
  28.     for (int i = 0; i < n; ++i)
  29.     {
  30.         for (int j = 0; j < n; ++j)
  31.         {
  32.             if (i == 0)
  33.                 mas[j] = matr[i][j];
  34.            
  35.             else if (matr[i][j] > mas[j])
  36.                     mas[j] = matr[i][j];
  37.         }
  38.     }
  39.    
  40.  
  41.     for (int* ptr = mas; ptr <= &mas[LengthOfArray]; ptr++)
  42.     {
  43.         std::cout << "address=" << ptr << "\tvalue=" << *ptr << std::endl;
  44.     }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment