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 |
小弟这段C++程序有问题么#include <iostream> #include <cmath> using namespace std; int main() { long double inp; long int l; cin>>inp>>l; long int n,d; double minerr=inp; for(long i=l;i>0;i--) { long int j=(long int)(inp*i); long double err=fabsl((long double)(j)/(long double)(i)-inp); if(minerr>=err) { n=j;d=i;minerr=err; } j++; err=fabsl((long double)(j)/(long double)(i)-inp); if(minerr>=err) { n=j;d=i;minerr=err; } } cout<<n<<' '<<d<<endl; system("pause"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator