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 |
请教一下,这样为什么不对啊,有人可以给些测试数据吗#include <iostream> //#include <cstring> #include <cmath> //#include <cstdlib> //#include <algorithm> //#include <string> using namespace std; int main() { double num; int limit; cin >> num >> limit; double min = 10000; int fi, fi2; for (int i=1; i <= limit; i++) { if ((int)(i*num+0.5) > limit ) break; double tmp = fabs(i*num-(int)(i*num+0.5)); if (min > tmp ) { min = tmp; fi = i; fi2 = (int)(i*num+0.5); } } cout << fi2 << ' ' << fi; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator