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

好吧,float错了,double过了

Posted by TSERROF at 2012-08-06 16:34:38 on Problem 1607
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
	int card,cnt=0;
	while(cin>>card)
	{
		double ans=0;
		double bottom=0;
		for (float i=1;i<=card;++i)
		{
			bottom=1.0/(2*i);
			ans+=bottom;
		}
		if(cnt++==0)cout<<"Cards  Overhang"<<endl;
		cout<<setw(5)<<card;
		cout.setf(ios::fixed);
		cout.precision(3); 
		cout<<setw(10)<<ans<<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