Predpogoj - Manipulacije razmerja v C ++ | Set 1 (aritmetika)
V C ++ the
- razmerje_equal
- Rate_not_equal
- Rate_Greater
- razmerje_lezijo
- Rate_Greater_equal
- Rate_less_equal
1. razmerje_equal: Ta predloga vzdevki preverja, ali razmerja v svojih argumentih so enaki . Vrne resnično, če se enakovredno vrne napačno. Vrne a Boolejski član stalnica 'Vrednost' .
2. Ratio_not_equal: Ta predloga vzdevki preverja, ali razmerja v svojih argumentih so ni enako . Vrne resnično, če ni enako, če se enako vrne napačno. Vrne a Boolejski član stalnica 'Vrednost' .
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; }
Izhod
Ratios are equal Ratios are equal
3. Ratio_Greater: Ta začasni vzdevek preveri, ali razmerje1 je večje od razmerja2 . To Vrne boolove član stalnica 'Vrednost' ki vrne resnično, če je razmerje1 večje od razmerja2, se vrne napačno.
4. Ratio_less: Ta začasni vzdevek preveri, ali razmerje1 je manj kot razmerje2 . To Vrne boolove član stalnica 'Vrednost' ki vrne resnično, če je razmerje1 manjše od razmerja2, se vrne napačno.
// 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; }
Izhod
ratio1 is not greater than ratio2 ratio1 is less than ratio2
5. Rate_Greater_equal: Ta začasni vzdevek preveri, ali razmerje1 je večje ali enako kot razmerje2 . To Vrne boolove član stalnica 'Vrednost' ki vrne resnično, če je razmerje1 večje ali enako kot razmerje2, ki se vrne napačno.
6. Ratio_less_equal: Ta začasni vzdevek preveri, ali razmerje1 je manjše ali enako kot razmerje2 . To Vrne boolove član stalnica 'Vrednost' ki vrne resnično, če je razmerje1 manj ali enako od razmerja2, ki se vrne napačno.
// 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; }
Izhod
ratio1 is greater or equal than ratio2 ratio1 is less or equal than ratio2