Verhältnismanipulationen in C++ | Set 2 (Vergleich)
Voraussetzung - Verhältnismanipulationen in C++ | Satz 1 (Arithmetik)
In C++ die
- Verhältnis_gleich
- Verhältnis_nicht_gleich
- ratio_greater
- ratio_less
- Verhältnis_größer_gleich
- Verhältnis_weniger_gleich
1. Verhältnis_gleich: Dieser Vorlagenalias prüft, ob die Verhältnisse in seinen Argumenten sind gleich . Gibt „true“ zurück, wenn gleich, andernfalls wird „false“ zurückgegeben. Es gibt a zurück boolesches Mitglied Konstante 'Wert' .
2. ratio_not_equal: Dieser Vorlagenalias prüft, ob die Verhältnisse in seinen Argumenten sind ungleich . Gibt „true“ zurück, wenn es nicht gleich ist, andernfalls gibt es „false“ zurück, wenn es gleich ist. Es gibt a zurück boolesches Mitglied Konstante 'Wert' .
// 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 ; }
Ausgabe
Ratios are equal Ratios are equal
3. Verhältnis_größer: Dieser temporäre Alias prüft, ob Verhältnis1 ist größer als Verhältnis2 . Es gibt ein boolesches Mitglied zurück Konstante 'Wert' Dies gibt „true“ zurück, wenn „ratio1“ größer als „ratio2“ ist, andernfalls wird „false“ zurückgegeben.
4. ratio_less: Dieser temporäre Alias prüft, ob Verhältnis1 ist kleiner als Verhältnis2 . Es gibt ein boolesches Mitglied zurück Konstante 'Wert' Dies gibt „true“ zurück, wenn „ratio1“ kleiner als „ratio2“ ist, andernfalls wird „false“ zurückgegeben.
// 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 ; }
Ausgabe
ratio1 is not greater than ratio2 ratio1 is less than ratio2
5. ratio_greater_equal: Dieser temporäre Alias prüft, ob Verhältnis1 ist größer oder gleich Verhältnis2 . Es gibt ein boolesches Mitglied zurück Konstante 'Wert' Dies gibt „true“ zurück, wenn Verhältnis1 größer oder gleich als Verhältnis2 ist, andernfalls wird „falsch“ zurückgegeben.
6. ratio_less_equal: Dieser temporäre Alias prüft, ob Verhältnis1 ist kleiner oder gleich Verhältnis2 . Es gibt ein boolesches Mitglied zurück Konstante 'Wert' Dies gibt „true“ zurück, wenn Verhältnis1 kleiner oder gleich als Verhältnis2 ist, andernfalls wird „falsch“ zurückgegeben.
// 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 ; }
Ausgabe
ratio1 is greater or equal than ratio2 ratio1 is less or equal than ratio2