前提条件 - C++ での比率操作 |セット1(算数)
C++ では、
- 比率が等しい
- 比率が等しくない
- 比率_大きい
- 比率なし
- 比率_大きい_等しい
- 比率なしの等しい
1.ratio_equal: このテンプレートのエイリアスは、 比率 その議論の中で 等しい 。等しい場合は true を返し、そうでない場合は false を返します。を返します ブール値メンバー 絶え間ない '価値' 。
2. 比率が等しくない: このテンプレートのエイリアスは、 比率 その議論の中にあるのは 等しくない 。等しくない場合は true を返し、等しい場合は false を返します。を返します ブール値メンバー 絶え間ない '価値' 。
CPP
// C++ code to demonstrate the working of // ratio_equal and ratio_not_equal #include #include // for ratio manipulation using namespace std; // Driver Code int main() { // Declaring ratios typedef ratio<10 100> ratio1; typedef ratio<1 10> ratio2; // Checking if ratios are equal using ratio_equal ratio_equal<ratio1 ratio2>::value ? cout << 'Ratios are equal' : cout << 'Ratios are not equal'; cout << endl; // Checking if ratios are not equal using // ratio_not_equal ratio_not_equal<ratio1 ratio2>::value ? cout << 'Ratios are not equal' : cout << 'Ratios are equal'; return 0; }
出力
Ratios are equal Ratios are equal
3.ratio_greater: この一時エイリアスは次のことをチェックします。 比率 1 は比率 2 より大きい 。それ ブール値メンバーを返します 絶え間ない '価値' これは、ratio1がratio2より大きい場合はtrueを返し、それ以外の場合はfalseを返します。
4. 比率なし: この一時エイリアスは次のことをチェックします。 比率 1 は比率 2 より小さい 。それ ブール値メンバーを返します 絶え間ない '価値' これは、ratio1がratio2より小さい場合にtrueを返し、それ以外の場合はfalseを返します。
// C++ code to demonstrate the working of // ratio_greater and ratio_less #include #include // for ratio manipulation using namespace std; // Driver Code int main() { // Declaring ratios typedef ratio<10 100> ratio1; typedef ratio<11 100> ratio2; // Checking if ratio1 is greater than ratio2 // using ratio_greater ratio_greater<ratio1 ratio2>::value ? cout << 'ratio1 is greater than ratio2' : cout << 'ratio1 is not greater than ratio2'; cout << endl; // Checking if ratio1 is less than ratio2 // using ratio_less ratio_less<ratio1 ratio2>::value ? cout << 'ratio1 is less than ratio2' : cout << 'ratio1 is not less than ratio2'; cout << endl; return 0; }
出力
ratio1 is not greater than ratio2 ratio1 is less than ratio2
5.ratio_greater_equal: この一時エイリアスは次のことをチェックします。 比率 1 は比率 2 以上です 。それ ブール値メンバーを返します 絶え間ない '価値' これは、ratio1がratio2より大きいか等しい場合にtrueを返し、それ以外の場合はfalseを返します。
6.ratio_less_equal: この一時エイリアスは次のことをチェックします。 比率 1 は比率 2 以下です 。それ ブール値メンバーを返します 絶え間ない '価値' これは、ratio1がratio2以下の場合にtrueを返し、それ以外の場合はfalseを返します。
// C++ code to demonstrate the working of // ratio_greater_equal and ratio_less_equal #include #include // for ratio manipulation using namespace std; // Driver Code int main() { // Declaring ratios typedef ratio<10 100> ratio1; typedef ratio<1 10> ratio2; // Checking if ratio1 is greater or equal than ratio2 // using ratio_greater_equal ratio_greater_equal<ratio1 ratio2>::value ? cout << 'ratio1 is greater or equal than ratio2' : cout << 'ratio1 is not greater or equal than ' 'ratio2'; cout << endl; // Checking if ratio1 is less or equal than ratio2 // using ratio_less_equal ratio_less_equal<ratio1 ratio2>::value ? cout << 'ratio1 is less or equal than ratio2' : cout << 'ratio1 is not less or equal than ratio2'; cout << endl; return 0; }
出力
ratio1 is greater or equal than ratio2 ratio1 is less or equal than ratio2