شرط أساسي - التلاعب بالنسب في C++ | المجموعة 1 (الحسابية)
في C++ ال
- نسبة_المساواة
- نسبة_غير_متساوية
- نسبة_أكبر
- نسبة_ليس
- نسبة_أكبر_تساوي
- نسبة_أقل_مساواة
1. النسبة_متساوية: يتحقق هذا الاسم المستعار للقالب مما إذا كان النسب في حججها متساوون . يُرجع صحيحًا إذا كان يساوي غير ذلك يُرجع خطأ. يعود أ عضو منطقي ثابت 'قيمة' .
2. النسبة_غير_متساوية: يتحقق هذا الاسم المستعار للقالب مما إذا كان النسب في حججها هي لا يساوي . يُرجع صحيحًا إذا لم يكن مساويًا، وإلا إذا كان متساويًا يُرجع خطأ. يعود أ عضو منطقي ثابت 'قيمة' .
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 وإلا تُرجع خطأ.
4. نسبة_ليس: يتحقق هذا الاسم المستعار المؤقت مما إذا النسبة 1 أقل من النسبة 2 . هو - هي إرجاع عضو منطقي ثابت 'قيمة' والذي يُرجع صحيحًا إذا كانت النسبة 1 أقل من النسبة 2 وإلا تُرجع خطأ.
// 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. النسبة_الأكبر_المتساوية: يتحقق هذا الاسم المستعار المؤقت مما إذا النسبة 1 أكبر أو تساوي النسبة 2 . هو - هي إرجاع عضو منطقي ثابت 'قيمة' والذي يُرجع صحيحًا إذا كانت النسبة 1 أكبر أو تساوي النسبة 2 وإلا تُرجع خطأ.
6. نسبة_ليس_متساوية: يتحقق هذا الاسم المستعار المؤقت مما إذا النسبة 1 أقل أو تساوي النسبة 2 . هو - هي إرجاع عضو منطقي ثابت 'قيمة' والتي تُرجع صحيحًا إذا كانت النسبة 1 أقل أو تساوي النسبة 2 وإلا تُرجع خطأ.
// 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