C++ 中的 Nesbitt 不等式

在本教程中,我们将编写一个程序来检查 nesbitt 不等式的有效性。

内斯比特不等式是 (a/(b + c)) + (b/(c + a)) + (c/(a + b))>= 1.5, a > 0, b > 0, c > 0

我们可以测试三个数是否满足 nesbitt 不等式。这是一个简单的程序。

示例

让我们看看代码。

#include <bits/stdc++.h>
using namespace std;
bool isValidNesbitt(double a, double b, double c) {
   double A = a / (b + c);
   double B = b / (a + c);
   double C = c / (a + b);
   double result = A + B + C;
      return result >= 1.5;
}
int main() {
   double a = 3.0, b = 4.0, c = 5.0;
   if (isValidNesbitt(a, b, c)) {
      cout << "Nesbitt's inequality is satisfied" << endl;
   }else {
      cout << "Nesbitt's inequality is not satisfied" << endl;
   }
return 0;
}
输出结果

如果你运行上面的代码,那么你会得到下面的结果。

Nesbitt's inequality is satisfied