Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴代码

Posted by 15686354699 at 2015-05-21 20:26:01 on Problem 1001
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		float f = in.nextFloat();
		while(f!=0.00){
			int count = 0;
			float sum =0f;
			for (int i = 2;;i++) {
				sum+=(1.0f/i);
				if(sum>=f){
					break;
				}else {
					count++;
				}
			}
			System.out.println(count+1+" card(s)");
			f = in.nextFloat();
		}
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator