Skip to content

Latest commit

 

History

History
71 lines (48 loc) · 1.17 KB

[0166] 分数到小数.md

File metadata and controls

71 lines (48 loc) · 1.17 KB
title tags categories author comments updated permalink mathjax top description date
[0166] 分数到小数
leetcode
leetcode
张学志
true
false
false
false
...
2019-12-31 16:02:46 -0800

题目描述

给定两个整数,分别表示分数的分子 numerator 和分母 denominator,以字符串形式返回小数。

如果小数部分为循环小数,则将循环的部分括在括号内。

示例 1:

输入: numerator = 1, denominator = 2
输出: "0.5"

示例 2:

输入: numerator = 2, denominator = 1
输出: "2"

示例 3:

输入: numerator = 2, denominator = 3
输出: "0.(6)"
Related Topics
  • 哈希表
  • 数学
  • 题目代码

    class Solution {
    public:
        string fractionToDecimal(int numerator, int denominator) {
    
        }
    };

    题目解析

    方法一

    方法二

    方法三