isless()函数与C ++中的示例
C ++ isless()函數 (C++ isless() function)
isless() function is a library function of cmath header, it is used to check whether the given first value is less than the second value. It accepts two values (float, double or long double) and returns 1 if the first value is less than the second value; 0, otherwise.
isless()函數是cmath標頭的庫函數,用于檢查給定的第一個值是否小于第二個值。 它接受兩個值( float , double或long double ),如果第一個值小于第二個值,則返回1。 0,否則。
Syntax of isless() function:
isless()函數的語法:
In C99, it has been implemented as a macro,
在C99中,它已實現為宏,
macro isless(x, y)In C++11, it has been implemented as a function,
在C ++ 11中,它已作為函數實現,
bool isless (float x , float y);bool isless (double x , double y);bool isless (long double x, long double y);Parameter(s):
參數:
x, y – represent the two values to be checked whether x is less than the y.
x,y –表示兩個要檢查的值,即x是否小于y 。
Return value:
返回值:
The returns type of this function is bool, it returns 1 if x is less than y; 0, otherwise.
該函數的返回類型為bool ,如果x小于y ,則返回1; 0,否則。
Example:
例:
Input:float x = 5.0f;float y = 15.0f;Function call:isless(x, y);Output:1C ++代碼演示isless()函數的示例 (C++ code to demonstrate the example of isless() function)
// C++ code to demonstrate the example of // isless() function#include <iostream> #include <cmath> using namespace std;int main() {cout << "isless(0.0f, -2.0f) : " << isless(0.0f, -2.0f) << endl;cout << "isless(10.0f, 20.0f) : " << isless(10.0f, 20.0f) << endl;cout << "isless(10.0f, 5.0f) : " << isless(10.0f, 5.0f) << endl;cout << "isless(-10.0f, -20.0f): " << isless(-10.0f, -20.0f) << endl;float x = 10.0f;float y = 5.0f;// checking using the conditionif (isless(x, y)) {cout << x << " is less than " << y << endl;}else {cout << x << " is not less than " << y << endl;}x = 9.0f;y = 10.0f;if (isless(x, y)) {cout << x << " is less than " << y << endl;}else {cout << x << " is not less than " << y << endl;}return 0; }Output
輸出量
isless(0.0f, -2.0f) : 0 isless(10.0f, 20.0f) : 1 isless(10.0f, 5.0f) : 0 isless(-10.0f, -20.0f): 0 10 is not less than 5 9 is less than 10Reference: C++ isless() function
參考: C ++ isless()函數
翻譯自: https://www.includehelp.com/cpp-tutorial/isless-function-with-example.aspx
總結
以上是生活随笔為你收集整理的isless()函数与C ++中的示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: algol语言_ALGOL的完整形式是什
- 下一篇: python的pass语句_Python