6
2025-04-30 13:06:42
发布于:江苏
1阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
int main() {
int a, b, c;
cin >> a >> b >> c;
int hypotenuse = max({a, b, c});
int leg1, leg2;
if (a == hypotenuse) {
leg1 = b;
leg2 = c;
} else if (b == hypotenuse) {
leg1 = a;
leg2 = c;
} else {
leg1 = a;
leg2 = b;
}
int smaller_leg = min(leg1, leg2);
int common_divisor = gcd(smaller_leg, hypotenuse);
int numerator = smaller_leg / common_divisor;
int denominator = hypotenuse / common_divisor;
cout << numerator << "/" << denominator << endl;
return 0;
}
这里空空如也
有帮助,赞一个