#include<iostream>
using namespace std;
void main() {
int a[] = { -1,0,9 };
int b[] = { -25,-10,10,11 };
int c[] = { 2,9,17,30,41 };
int a_, b_, c_;
int d =abs(a[0]-b[0])+abs(b[0]-c[0])+abs(c[0]-a[0]);
for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) {
for (int j = 0; j < sizeof(b) / sizeof(b[0]); j++) {
for (int k = 0; k < sizeof(c) / sizeof(c[0]); k++) {
d = min(abs(a[i] - b[j]) + abs(b[j] - c[k]) + abs(c[k] - a[i]),d);
}
}
}
for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) {
for (int j = 0; j < sizeof(b) / sizeof(b[0]); j++) {
for (int k = 0; k < sizeof(c) / sizeof(c[0]); k++) {
if (abs(a[i] - b[j]) + abs(b[j] - c[k]) + abs(c[k] - a[i]) == d)
{
a_ = a[i], b_ = b[j], c_ = c[k];
}
}
}
}
cout << d<<' '<<a_<<' '<<b_<<' '<<c_;
}
01-13
878
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-14
2741
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-09
747
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-22
5449
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)