-
Notifications
You must be signed in to change notification settings - Fork 4
/
SER6.cpp
45 lines (42 loc) · 865 Bytes
/
SER6.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//Author Pulkit Singh
#include <iostream>
using namespace std;
void findClosest(int A[], int B[], int C[], int p, int q, int r)
{
int diff = 100;
int res_i =0, res_j = 0, res_k = 0;
int i=0,j=0,k=0;
while (i < p && j < q && k < r)
{
int minimum = min(A[i], min(B[j], C[k]));
int maximum = max(A[i], max(B[j], C[k]));
if (maxiAmum-minimum < diff)
{
res_i = i, res_j = j, res_k = k;
diff = maximum - minimum;
}
if (diff == 0) break;
if (A[i] == minimum) i++;
else if (B[j] == minimum) j++;
else k++;
}
cout << A[res_i] << " " << B[res_j] << " " << C[res_k];
}
int main()
{
int A[10],B[10],C[10],p,q,r;
cin>>p;
for(int i=0;i<p;i++){
cin>>A[i];
}
cin>>q;
for(int i=0;i<q;i++){
cin>>B[i];
}
cin>>r;
for(int i=0;i<r;i++){
cin>>C[i];
}
findClosest(A, B, C, p, q, r);
return 0;
}