我正在写一个函数,这是我到目前为止所做的:
template <typename T>
M2SA(T* A, size_t m, T* B, size_t n)
{
/* Require both arrays be nonempty */
if (m == 0 || n == 0)
{
throw ("Cannot find median of 2 sorted arrays if either is empty!";)
}
}
Run Code Online (Sandbox Code Playgroud)
有什么方法可以if (m == 0 || n == 0)
使用位比较操作来优化条件???
我正在尝试做的是在函数内部的注释块中描述:
bool CalculusWizard::partitionEquation(const std::string & eq, std::string & eq1,
std::string & eq2, CalcWizConsts::eqOps & oper)
{
/* Given an equation eq, partion eq into
eq = eq1 oper eq2
where oper is the operator with the lowest precedence,
e.g. eq = "x*sin(x)+x^2" --> eq1 = "x*sin(x)", oper = ADDITION, eq2 = "x^2".
If there is no operator, e.g. eq = "x", then oper = NONE.
The error checking is done in this function. If there is a syntactical error
in …
Run Code Online (Sandbox Code Playgroud)