Vla_DOS

Untitled

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