题目及测试
package pid166;
/* 分数到小数
给定两个整数,分别表示分数的分子 numerator 和分母 denominator,以字符串形式返回小数。
如果小数部分为循环小数,则将循环的部分括在括号内。
示例 1:
输入: numerator = 1, denominator = 2
输出: "0.5"
示例 2:
输入: numerator = 2, denominator = 1
输出: "2"
示例 3:
输入: numerator = 2, denominator = 3
输出: "0.(6)"
*/
public class main {
public static void main(String[] args) {
int[] testTable1 = new int[]{1,2,2};
int[] testTable2 = new int[]{2,1,3};
for(int i=0;i<testTable1.length;i++){
test(testTable1[i],testTable2[i]);
}
}
private static void test(int ito,int ito2) {
Solution solution = new Solution();
String rtn;
long begin = System.currentTimeMillis();
System.out.print(ito+" "+ito2);
System.out.println();
//开始时打印数组
rtn = solution.fractionToDecimal(ito,ito2);//执行程序
long end = System.currentTimeM