UVA - 11809 Floating-Point Numbers
2015-03-18 00:53
288 查看
UVa11809 Floating-Point Numbers
时间限制:3.000秒
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=830&page=show_problem&problem=2909
小白书第三章的最后一题,理解上有些难度,参考了一篇很好的文章,还是看不太懂。以后再认真看看。
先贴下自己的代码:
在贴下找到的文章
http://blog.csdn.net/crazysillynerd/article/details/43339157
时间限制:3.000秒
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=830&page=show_problem&problem=2909
小白书第三章的最后一题,理解上有些难度,参考了一篇很好的文章,还是看不太懂。以后再认真看看。
先贴下自己的代码:
#include <iostream> #include <sstream> #include <string> #include <cmath> #include<cstring> using namespace std; const double DET = 1e-4; int main() { double M[20][40]; long long E[20][40]; // 打表 for (int i = 0; i <= 9; ++i) for (int j = 1; j <= 30; ++j) { double m = 1 - pow(2, -1 - i), e = pow(2, j) - 1; double t = log10(m) + e * log10(2); E[i][j] = t; M[i][j] = pow(10, t - E[i][j]); } // 输入并输出结果 char in[32]; while (cin >> in) { if (strcmp(in, "0e0") == 0) break; double a; long long int b; *(strchr(in, 'e')) = ' '; //返回‘e’首次出现的位置的指针。 sscanf(in, "%lf %lld", &a, &b); for (int i = 0; i <= 9; i++) { for (int j = 1; j <= 30; j++) { if (fabs(M[i][j] - a)<DET && E[i][j] == b) printf("%d %d\n", i, j); } } } return 0; }
在贴下找到的文章
http://blog.csdn.net/crazysillynerd/article/details/43339157
相关文章推荐
- UVa-11809 - Floating-Point Numbers
- UVA - 11809 Floating-Point Numbers
- UVA 11809 Floating-Point Numbers
- uva 11809 - Floating-Point Numbers(浮点数)
- UVa 11809 Floating-Point Numbers
- UVA 11809 - Floating-Point Numbers【浮点数】
- UVA 11809 Floating-Point Numbers(暴力)
- UVa11809-Floating-Point Numbers
- UVA-11809 Floating-Point Numbers
- UVA 11809 Floating-Point Numbers
- uva - 11809 - Floating-Point Numbers
- UVA - 11809 Floating-Point Numbers
- UVa 11809 Floating-Point Numbers (浮点数)
- UVA 11809 - Floating-Point Numbers
- Uva - 11809 - Floating-Point Numbers
- uva 11809 Floating-Point Numbers
- Uva - 11809 - Floating-Point Numbers
- UVA11809 - Floating-Point Numbers
- 【习题 3-12 UVA - 11809】Floating-Point Numbers
- UVa 11809 Floating-Point Numbers