Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define flush cin.ignore(numeric_limits<streamsize>::max(),'\n')
- #define FASTERIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define NL cout<<'\n';
- #define pi acos(-1.0) //3.1415926535897932384626
- #define pb push_back
- #define mk make_pair
- #define mx 1000005
- #define EPS 1e-10
- #define dpoint(x) fixed<<setprecision(x)
- # define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
- typedef long long int ll;
- typedef double dl;
- typedef unsigned long long int ull;
- int *find_min_mx(int *arr, int n){
- int min=INT_MAX, max = 0;
- for(int i=0; i<n; i++){
- if(arr[i]<min)min = arr[i];
- if(arr[i]>max)max = arr[i];
- arr[0] = min;
- arr[1] = max;
- }
- return arr;
- }
- int main() {
- #ifdef anikakash
- clock_t tStart = clock();
- freopen("input.txt", "r", stdin);
- freopen("tmp.txt", "w", stdout);
- #endif
- FASTERIO; //cmt when use scanf & printf ;
- int n; cin>>n;
- int arr[n];
- for(int i=0; i<n; i++)cin>>arr[i];
- int *ptr = find_min_mx(arr,n);
- cout<<"Max value "<<*(ptr)<<endl;
- cout<<"Min value "<<*(ptr+1)<<endl;
- #ifdef anikakash
- fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement