MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / third

Function third

CPP/array-2d/find_3rd_max.cpp:3–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include<iostream>
2using namespace std;
3void third(int arr[],int n){
4int first=arr[0];
5int j=0;
6 for(int i=0;i<n;i++)
7 {
8 if(arr[i]>first)
9 first=arr[i];
10 }
11 int second = INT_MIN;
12 for (int i = 0; i < n; i++)
13 if (arr[i] > second && arr[i] < first)
14 second = arr[i];
15
16 int third = INT_MIN;
17 for (int i = 0; i < n; i++)
18 if (arr[i] > third && arr[i] < second)
19 third = arr[i];
20 cout<<third;
21}
22int main(){
23 int arr[]={1,34,65,87,9,78};
24 int n=sizeof(arr)/sizeof(arr[0]);

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected