zoukankan      html  css  js  c++  java
  • codevs 1203 判断浮点数是否相等

    http://codevs.cn/problem/1203/

    1203 判断浮点数是否相等

     

     时间限制: 1 s
     空间限制: 128000 KB
     题目等级 : 青铜 Bronze
     
     
    题目描述 Description
    给出两个浮点数,请你判断这两个浮点数是否相等
    输入描述 Input Description
    输入仅一行,包含两个浮点数
    输出描述 Output Description
    输出仅一行,如果相等则输出yes,否则输出no。
    样例输入 Sample Input
    2.980000001 2.9800000000001
    样例输出 Sample Output
    yes
    数据范围及提示 Data Size & Hint
    我们一般认为两个浮点数相等,当且当他们之间的误差不超过1e-8。
     
    分析:
     
    水题
     
    AC代码:
     
     1 #include <stdio.h>
     2 #include <algorithm>
     3 #include <iostream>
     4 #include <string.h>
     5 #include <string>
     6 #include <math.h>
     7 #include <stdlib.h>
     8 #include <queue>
     9 #include <stack>
    10 #include <set>
    11 #include <map>
    12 #include <list>
    13 #include <iomanip>
    14 #include <vector>
    15 #pragma comment(linker, "/STACK:1024000000,1024000000")
    16 #pragma warning(disable:4786)
    17 
    18 using namespace std;
    19 
    20 const int INF = 0x3f3f3f3f;
    21 const int MAX = 10000 + 10;
    22 const double eps = 1e-8;
    23 const double PI = acos(-1.0);
    24 
    25 int main()
    26 {
    27     float a , b;
    28     while(~scanf("%f %f", &a , &b))
    29     {
    30         if(fabs(a - b) <= eps)
    31             printf("yes
    ");
    32         else
    33             printf("no
    ");
    34     }
    35     return 0;
    36 }
    View Code
    悠游天地间 all rights reserved. © 2013 -- 1 << 64
  • 相关阅读:
    c#获取指定时区的日期
    项目版本管理
    iis部署网站
    浏览器测试string是否为图片
    网站中挂视频
    百度地图调用
    mvc actionresult返回各种文件
    Coursera机器学习week7 单元测试
    Coursera机器学习week7 笔记
    牛客练习赛12 AB
  • 原文地址:https://www.cnblogs.com/jeff-wgc/p/4454137.html
Copyright © 2011-2022 走看看