Předpoklad - Manipulace poměru v C ++ | Sada 1 (aritmetika)
V C ++
pole seřazené v jazyce Java
- poměr_equal
- poměr_not_equal
- poměr_greater
- poměr_less
- poměr_greater_equal
- poměr_less_equal
1. poměr_equal: Tato alias šablony zkontroluje, zda poměry ve svých argumentech jsou stejné . Vrátí true, pokud se rovný jinak vrátí FALSE. Vrátí a Boolean člen konstantní 'hodnota' .
2. poměr_not_equal: Tato alias šablony zkontroluje, zda poměry Ve svých argumentech jsou nerovná . Vrátí true, pokud se nerovná jinak, pokud se stejný vrátí false. Vrátí a Boolean člen konstantní 'hodnota' .
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; }
Výstup
Ratios are equal Ratios are equal
3. poměr_greater: Tento dočasný alias zkontroluje, zda poměr1 je větší než poměr2 . To Vrátí člena Boolean konstantní 'hodnota' který vrací pravdu, pokud je poměr větší než poměr2 jinak vrátí false.
4. poměr_less: Tento dočasný alias zkontroluje, zda poměr1 je menší než poměr2 . To Vrátí člena Boolean konstantní 'hodnota' který vrací pravdu, pokud je poměr1 menší než poměr2 jinak vrátí 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; }
Výstup
ratio1 is not greater than ratio2 ratio1 is less than ratio2
5. poměr_greater_equal: Tento dočasný alias zkontroluje, zda poměr1 je větší nebo stejný než poměr2 . To Vrátí člena Boolean konstantní 'hodnota' který vrací pravdu, pokud je poměr větší nebo stejný než poměr2 jinak vrací false.
6. poměr_less_equal: Tento dočasný alias zkontroluje, zda poměr1 je méně nebo stejný než poměr2 . To Vrátí člena Boolean konstantní 'hodnota' který vrací pravdu, pokud je poměr méně nebo stejný než poměr2 jinak vrací false.
vypnutí režimu vývojářeCPP
// 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; }
Výstup
ratio1 is greater or equal than ratio2 ratio1 is less or equal than ratio2