日期:2014-05-18 浏览次数:20791 次
class MyClass { int _a; int _b; public MyClass(int a, int b) { int min, max; if (a < b) { min = a; max = b; } else { min = b; max = a; } while (max % min != 0) { int temp = max; max = min; min = temp % min; } int gcd = min; _a = a / gcd; _b = b / gcd; } public void Show() { Console.WriteLine("{0}/{1}", _a, _b); } }