inhuman_Arif

Array 1

Sep 29th, 2021
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5.  
  6. int main()
  7. {
  8.     #ifndef ONLINE_JUDGE
  9.         freopen("input.txt", "r", stdin);
  10.         freopen("output.txt", "w", stdout);
  11.     #endif
  12.  
  13.     int n;
  14.     cin >> n;
  15.     int arr[n];
  16.     int min=1e7,max=-1000007;
  17.     for(int i=0;i<n;i++)
  18.         cin >> arr[i];
  19.     for(int i=0;i<n;i++)
  20.     {
  21.         if(arr[i]<min)
  22.             min=arr[i];
  23.         if(arr[i]>max)
  24.             max=arr[i];
  25.     }
  26.     cout << min << " " << max << endl;
  27.    
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment