Предпоставка - Съотношение манипулации в C ++ | Комплект 1 (аритметика)
В C ++ the
- съотношение_qual
- ratio_not_equal
- съотношение_генератор
- съотношение_ без
- съотношение_грейтър_ек
- ratio_less_qual
1. съотношение_еклен: Този псевдоним на шаблона проверява дали съотношения в своите аргументи са равни . Връща True, ако Equal Else се върне false. Връща a Булев член константа "стойност" .
2. Ratio_not_equal: Този псевдоним на шаблона проверява дали съотношения В неговите аргументи са не е равен . Връща True, ако не е равен друго, ако равни връщания невярно. Връща a Булев член константа "стойност" .
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. съотношение_грейдер: Този временен псевдоним проверява дали съотношението1 е по -голямо от съотношението2 . То Връща булев член константа "стойност" което връща вярно, ако съотношението1 е по -голямо от съотношението2 else връща невярно.
4. Съотношение_ безпада: Този временен псевдоним проверява дали съотношението1 е по -малко от съотношението2 . То Връща булев член константа "стойност" което връща true, ако съотношението1 е по -малко от съотношението2 else връща 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. съотношение_грейтър_qual: Този временен псевдоним проверява дали съотношението1 е по -голямо или равно от съотношението2 . То Връща булев член константа "стойност" което връща вярно, ако съотношението1 е по -голямо или равно от съотношението2 else връща невярно.
6. ratio_less_equal: Този временен псевдоним проверява дали съотношението1 е по -малко или равно от съотношението2 . То Връща булев член константа "стойност" което връща вярно, ако съотношението1 е по -малко или равно, отколкото съотношението2 else връща 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