tnk #206(2007/07/05 17:12 GMT) [ Java ] Rating0/0=0.00
出題者が回答していいのかな・・・。 Java 1.5以降です。Auto Boxingって楽だなあ。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
public static String getDecimal(long a, long b) { java.util.Vector<Long> nums = new java.util.Vector<Long>(); StringBuffer res = new StringBuffer("0."); while (true) { nums.add(a); a *= 10; res.append(a/b); a %= b; if (a == 0) { return res.toString(); } if (nums.contains(a)) { int off = nums.indexOf(a) + 2; return res.substring(0,off) + "{" + res.substring(off) + "}"; } } }
Rating0/0=0.00-0+
[ reply ]
tnk
#206()
[
Java
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]