这个 比率不相等 是C++中的一个内置函数,它检查两个给定的比率是否相等或相等。
null
语法:
template < class ratio1_name, class ratio2_name > ratio_not_equal
模板参数: 该函数接受两个模板参数 比率1 和 比率2 这些都是可以比较的。
返回值: 如果比率不相等,则函数返回true,否则返回false。
下面的程序演示了该功能:
项目1:
// C++ program to illustrate the // ratio_not_equal function #include <iostream> #include <ratio> using namespace std; int main() { typedef ratio<3, 9> ratio1; typedef ratio<1, 3> ratio2; // If both the ratios are not same if (ratio_not_equal<ratio1, ratio2>::value) cout << "Both ratio are not equal" ; else cout << "Both ratio are equal" ; return 0; } |
输出:
Both ratio are equal
项目2:
// C++ program to illustrate the // ratio_equal function #include <iostream> #include <ratio> using namespace std; int main() { typedef ratio<1, 2> ratio1; typedef ratio<5, 4> ratio2; // If both the ratios are not same if (ratio_not_equal<ratio1, ratio2>::value) cout << "Both ratio are not equal" ; else cout << "Both ratio are equal" ; return 0; } |
输出:
Both ratio are not equal
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END