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

Re:运行不了,请大家帮忙看看

Posted by heartnheart at 2009-10-10 16:46:29 on Problem 1003
In Reply To:运行不了,请大家帮忙看看 Posted by:xenon168 at 2009-05-16 19:57:52
#include<iostream>
using namespace std;

int main()
{
	int i,j;
	 
	float test[100];
	for(i=0;i<=100;i++){
		cin>>test[i];
		if((test[i]==0)||(test[i]<0)||(test[i]>5.2))
			break;		
	}
	for(i=0;i<=100;i++){
        float sum=0;//把sum的声明拿这来,每次循环都要归零
		if(test[i]==0)
			break;
		for(j=2;j<1000;j++)//改为1000,否则5.19无法计算
			{
                          sum=sum+(1.0/j);//将1改为1.0
		                  if(sum>test[i])
		                  {
			              cout<<j-1<<"card(s)"<<endl;
                          break;
                          }
		}
		

	}
	 system("pause");
	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