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

why waaaaaaaaaaaaaaaaaaaaaaaaaa!

Posted by gxiverson at 2005-01-05 14:57:09 on Problem 1607
#include<iostream.h>
#include<iomanip.h>
double fac(int n)
{
	double f;
	if(n==1) f=0.5;
	else f=fac(n-1)+1.0/(2*n);
	return f;
}
void main()
{
    long int n;
	cout<<"Cards  Overhang "<<endl;
	while(cin){
		cin>>n;
		if(n<=0) cout<<"    0     0.000"<<endl;
		else if(n<=3) cout<<setw(5)<<n<<"  "<<setw(8)<<setiosflags(ios::showpoint)<<setprecision(3)<<fac(n)<<endl;
		else
			cout<<resetiosflags(ios::fixed)<<setw(5)<<n<<"  "<<setw(8)<<setprecision(4)<<fac(n)<<endl;
	}
}

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