#include <cmath> #include <iomanip> #include <iostream> using namespace std; int main() { int x1, x2, y1, y2; cin >> x1 >> y1; cin >> x2 >> y2; double dE = (double) sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); double dM = (double) abs(x1 - x2) + abs(y1 - y2); double res = abs(dM - dE); cout << fixed << setprecision(9) << res << endl; } // 64 位输出请用 printf("%lld")
sqrt():求开根号
abs():求绝对值