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

写第一个程序就wrong answer,大家帮忙看看那

Posted by Tim at 2006-02-19 16:04:16 on Problem 1003
#include<iostream>
using namespace std;

int number(float f)
{
	int i=1;
	float s=0;
	while(s<=f)
	{
		i++;
		s+=1.0/i;
	}
	return i-1;
}

int main()
{
	int j=0,i=0;
	float a[100];
	while(1)
	{
		cin>>a[i];
		if(a[i]==0.00)
			break;
		i++;
	}
	for(j=0;j<i;j++)
		cout<<number(a[j])<<" (cards)"<<endl;
	return 0;
}


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