* 我们知道分数由分子和分母组成,所以给定你两个正整数,第一的代表分子,第二个代表分母,你能不能把他们化作最简的形式输出? 例: inp t: 4 8 o t p t: 12 * 辗转相除法 f nc test(molec , denominator: int){ if molec lar = 0 && denominator = 0 { ret rn } let commondivisor = getcommondivisor(n mber1: molec lar, n mber2: denominator) print("the greatest common divisor is (commondivisor)") print("the minimalist is (molec lar  commondivisor)(denominator  commondivisor) ") } 递归 f nc getcommondivisor(n mber1: int, n mber2: int) - int { let remainder = n mber1 % n mber2 if remainder == 0 { ret rn n mber2 } else { ret rn getcommondivisor(n mber1: n mber2, n mber2: remainder) } } test(molec lar: 100, denominator: 200) * 我们都知道数字的分数形式化简,那当然我们还有字幕形式的分子分母化简,给你两个字母(都是合法的小写形式),请你输出他的最简形式 例: inp t: a ab o tp t: 1b * 猜想:通过哈希表摘出分子分母分别的字母数量,然后进行删减最后拼装 f nc test(molec , denominator: string){ var mdic = [] var d = "" var m = "" 将分子添加入哈希表 for mc in molec lar.characters{ if var a = mdic[mc] { a += 1 mdic[mc] = a } else { mdic[mc] = 1 } } 遍历分母对哈希表进行删改 for dc in denominator.characters { if var a = mdic[dc] { if a !