Skip to content

Commit 49e300a

Browse files
Create Max and Min in an array.cpp
1 parent 17e10cb commit 49e300a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
void reverse(int arr[], int n, int start, int end){
5+
while(start<=end){
6+
swap(arr[start],arr[end]);
7+
start++;
8+
end--;
9+
reverse(arr,n,start+1,end-1);
10+
}
11+
}
12+
13+
int main(){
14+
int n;
15+
cin>>n;
16+
int arr[n];
17+
for(int i=0; i<n; i++) cin>>arr[i];
18+
int min=arr[0],max=arr[0];
19+
for(int i=0; i<n; i++){
20+
if(arr[i]<min) min =arr[i];
21+
if(arr[i]>max) max =arr[i];
22+
}
23+
cout<<"min: "<<min<<endl;
24+
cout<<"max: "<<max<<endl;
25+
}

0 commit comments

Comments
 (0)