Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
113
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 "Windows.h"
  3.  
  4.  
  5. using namespace std;
  6. int main() {
  7.     int n, m;
  8.     cout << "Enter N: ";
  9.     cin >> n;
  10.     cout << endl;
  11.     cout << "Enter M: ";
  12.     cin >> m;
  13.     cout << endl;
  14.  
  15.     HANDLE heap = HeapCreate(0, (n*m*sizeof(int)), (n*m*sizeof(int)));
  16.     int **arr = (int**)HeapAlloc(heap, 0, (n*sizeof(int*)));
  17.  
  18.     for (int i = 0; i < n; i++)
  19.     {
  20.         arr[i] = (int*)HeapAlloc(heap, 0, (m*sizeof(int)));
  21.         for (int j = 0; j < m; j++)
  22.         {
  23.             arr[i][j] = (rand() % 10);
  24.             cout <<  arr[i][j] << "    ";
  25.         }
  26.         cout << endl;
  27.     }
  28.     cout << endl;
  29.  
  30.     int max = -1, min = 100;
  31.     for (int i = 0; i < n; i++)
  32.     {
  33.         for (int j = 0; j < m; j++)
  34.         {
  35.             if (arr[i][j] > max)
  36.             {
  37.                 max = arr[i][j];
  38.             }
  39.             else if (arr[i][j] < min)
  40.             {
  41.                 min = arr[i][j];
  42.             }
  43.         }
  44.     }
  45.     cout << "max: " << max << endl;
  46.     cout << "min: " << min << endl;
  47.  
  48.  
  49.     HeapDestroy(heap);
  50.  
  51.  
  52.     //delete [] arr;
  53.  
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement