File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < time.h>
3
+ #include < cmath>
4
+ #define e 2.71828
5
+ using namespace std ;
6
+
7
+ void printBestCandidate (int candidate[], int n)
8
+ {
9
+ int sample_size = round (n/e);
10
+ cout << " \n\n Sample size is " << sample_size << endl;
11
+ int best = 0 ;
12
+ for (int i = 1 ; i < sample_size; i++)
13
+ if (candidate[i] > candidate[best])
14
+ best = i;
15
+ for (int i = sample_size; i < n; i++)
16
+ if (candidate[i] >= candidate[best]) {
17
+ best = i;
18
+ break ;
19
+ }
20
+ if (best >= sample_size)
21
+ cout << endl << " Best candidate found is "
22
+ << best + 1 << " with talent "
23
+ << candidate[best] << endl;
24
+ else
25
+ cout << " Couldn't find a best candidate\n " ;
26
+ }
27
+
28
+ int main ()
29
+ {
30
+ int n;
31
+ cin >> n;
32
+ int candidate[n];
33
+ cout << " Enter number of talents of the candidates\n " ;
34
+ for (int i = 0 ; i < n; i++)
35
+ cin >> candidate[i];
36
+ cout << " Candidate : " ;
37
+ for (int i = 0 ; i < n; i++)
38
+ cout << i + 1 << " " ;
39
+ cout << endl;
40
+ cout << " Talents : " ;
41
+ for (int i = 0 ; i < n; i++)
42
+ cout << candidate[i] << " " ;
43
+ printBestCandidate (candidate, n);
44
+ return 0 ;
45
+ }
You can’t perform that action at this time.
0 commit comments