Preduvjet - Manipulacije omjera u C ++ | SET 1 (aritmetika)
U C ++
- omjer_equal
- omjer_not_equal
- omjer_gar
- omjer_lej
- omjer_greater_equal
- omjer_less_equal
1. Omjer_equal: Ovaj pseudonim predloška provjerava je li omjeri u svojim argumentima su jednaki . Vraća istinito ako se jednaka drugo vrati lažno. Vraća a Booleov član konstanta 'vrijednost' .
2. omjer_not_equal: Ovaj pseudonim predloška provjerava je li omjeri u njegovim argumentima jesu nije jednak . Vraća istinito ako nije jednako drugo ako jednaka vraća lažno. Vraća a Booleov član konstanta 'vrijednost' .
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; }
Izlaz
Ratios are equal Ratios are equal
3. Odnos_Grater: Ovaj privremeni alias provjerava je li omjer1 je veći od omjera2 . To Vraća booleovog člana konstanta 'vrijednost' što vraća istinu ako je omjer1 veći od omjera2, a else vraća lažno.
4. omjer_less: Ovaj privremeni alias provjerava je li Omjer1 je manji od omjera2 . To Vraća booleovog člana konstanta 'vrijednost' što vraća istinu ako je omjer1 manji od omjera2, a else vraća laž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; }
Izlaz
ratio1 is not greater than ratio2 ratio1 is less than ratio2
5. omjer_geater_equal: Ovaj privremeni alias provjerava je li omjer1 je veći ili jednak od omjera2 . To Vraća booleovog člana konstanta 'vrijednost' što vraća istinu ako je omjer1 veći ili jednak od omjera2, a else vraća lažno.
6. Odnos_less_equal: Ovaj privremeni alias provjerava je li omjer1 je manji ili jednak od omjera2 . To Vraća booleovog člana konstanta 'vrijednost' što vraća istinu ako je omjer1 manji ili jednak od omjera2, a drugi vraća laž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; }
Izlaz
ratio1 is greater or equal than ratio2 ratio1 is less or equal than ratio2