ratio_not_equal是C++ STL中的內置函數,用於檢查兩個給定的比率是否相等或相等。
用法:
template ratio_not_equal
模板參數:該函數接受兩個要比較的模板參數ratio1和ratio2。
返回值:如果比率不相等,則該函數返回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
相關用法
- C++ cin get()用法及代碼示例
- C++ iswprint()用法及代碼示例
- C++ iswgraph()用法及代碼示例
- C++ std::allocator()用法及代碼示例
- C++ ratio_equal()用法及代碼示例
- C++ mbrtoc16()用法及代碼示例
- C++ mbrtoc32()用法及代碼示例
- C++ negative_binomial_distribution用法及代碼示例
- C++ ios bad()用法及代碼示例
- C++ ios eof()用法及代碼示例
注:本文由純淨天空篩選整理自Twinkl Bajaj大神的英文原創作品 ratio_not_equal() in C++ with examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。