提交时间:2025-07-21 22:46:23

运行 ID: 335144

#include <iostream> #include <algorithm> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; // 将三条边排序,方便判断 int sides[3] = {a, b, c}; sort(sides, sides + 3); int x = sides[0], y = sides[1], z = sides[2]; // x ≤ y ≤ z // 检查是否为直角三角形 if (x * x + y * y == z * z) { cout << z * z << endl; // 是直角三角形,输出斜边平方 } else { // 不是直角三角形,计算所有可能的两边组合的斜边平方 int max_hypotenuse_square = max({ x * x + y * y, x * x + z * z, y * y + z * z }); cout << max_hypotenuse_square << endl; } return 0; }