向上取整:
a / b的向上取整:
int cdiv(int a,int b)// a/b的向上取整
{
return (a b - 1) / b;
}
如果求m n的平均数向上取整即 a = m n b = 2;
----> (m n 1) / 2;
向下取整:
直接a / b:
如果求m n的平均数,即a = m n, b = 2
------> (m n) / 2;
向上取整:
a / b的向上取整:
int cdiv(int a,int b)// a/b的向上取整
{
return (a b - 1) / b;
}
如果求m n的平均数向上取整即 a = m n b = 2;
----> (m n 1) / 2;
向下取整:
直接a / b:
如果求m n的平均数,即a = m n, b = 2
------> (m n) / 2;