You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
380 B
20 lines
380 B
#include <iostream>
|
|
int a, b, x, y;
|
|
|
|
int main() {
|
|
std::cin >> a >> b >> x >> y int path1;
|
|
int path2;
|
|
int path3;
|
|
int ans;
|
|
path1 = std::abs(a - b);
|
|
path2 = std::abs(a - x) + std::abs(y - b);
|
|
path3 = std::abs(a - y) + std::abs(x - b);
|
|
ans = path1;
|
|
if (path2 < ans) {
|
|
ans = path2;
|
|
}
|
|
if (path3 < ans) {
|
|
ans = path3;
|
|
}
|
|
std::cout << ans << std::endl;
|
|
}
|
|
|