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 |
好吧,float错了,double过了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator