SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. const int N = 10;
  4. typedef int A[N];
  5. void func(int arr[], int n);
  6. int main() {
  7.     int n;
  8.     const int r = 10;
  9.     int A[r];
  10.     cout << "Elements: |";
  11.     for (int r = 0; r < N; r++)
  12.     {
  13.         A[r] = rand() % 10;
  14.         cout << A[r] << "|";
  15.     }
  16.     n = N;
  17.     func(A, n);
  18.     return 0;
  19. }
  20. void func(int arr[] , int n)
  21. {
  22.     n = N;
  23.     int min, max;
  24.     max = arr[0];
  25.     min = arr[0];
  26.     for (int s = 0; s < N - 1; s++)
  27.     {
  28.         if (max < arr[s+1]) max = arr[s+1];
  29.         if (min > arr[s+1]) min = arr[s+1];
  30.     }
  31.     cout << "Min: " << min << endl;
  32.     cout << "Max: " << max << endl;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top