zoukankan      html  css  js  c++  java
  • C++中的 Round(),floor(),ceil()

                                                                2.1             2.6              -2.1              -2.6
    floor : 不大于自变量的最大整数             2                2                  -3                  -3
    ceil   :不小于自变量的最大整数              3                3                  -2                  -2
    round:四舍五入到最邻近的整数             2                3                  -2                  -3

    round(num,num_dight) 把num精确到num_dight位数
    floor(),ceil() 需包含头文件<math.h>

    C++中没有直接的round函数 需自己建立
    double round(double r)
    {
        return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
    }
  • 相关阅读:
    POJ 1466 最大独立点集
    POJ 3159 差分约束
    POJ 3411 DFS
    POJ 2665 模拟,,
    POJ 3134 Power Calculus ID-DFS +剪枝
    POJ 1543 暴搜
    455. Assign Cookies
    715. Range Module
    530. Minimum Absolute Difference in BST
    493. Reverse Pairs(BST, BIT, MergeSort)
  • 原文地址:https://www.cnblogs.com/zhuruibi/p/8972605.html
Copyright © 2011-2022 走看看