| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
why waaaaaaaaaaaaaaaaaaaaaaaaaa!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator