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 |
Re:疯了完全没理由啊In Reply To:疯了完全没理由啊 Posted by:ilmlj at 2014-02-05 16:37:30 > 对于第1003题为什么这样是答案是错误的呢?? > 我找了运行可以通过的答案,几乎没差别啊?? > 求教大神啊 > > 下面是我的答案: > public class Main{ > public static void main(String[] args){ > String str; > float c,sum = 0; > int i; > Scanner scanner = new Scanner(System.in); > str = scanner.nextLine(); > while(!str.equals("0.00")){ > c = Float.valueOf(str).floatValue(); > for(i=1;sum<c;i++){ > sum = sum + 1f/(i+1); > } > System.out.printf("%d card(s)\n",i-1); > str = scanner.next(); > } > > } > } > sum 用之前初始化 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator