| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
大家帮我看看这段java的什么地方判断错了总是结果wrong answer
感谢了
已经提交了10多次都没通过
郁闷呀
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
static float[] cardLength = new float[1000];
static private int cacuMinCards(float length){
for (int i = 2; ;i++)
{
if((length - (float)1/i) <= 0)
return i - 1;
length = length - (float)1/i;
}
}
public static void main(String[] args) {
for (int i = 0;; i++){
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
cardLength[i] = Float.parseFloat(br.readLine());
if (0 == cardLength[i]) break;
}
catch (Exception e) {
break;
}
}
for (int i = 0; i < cardLength.length; i++) {
if (0 == cardLength[i]) break;
System.out.println(cacuMinCards(cardLength[i]) + " card(s)");
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator