在C++中,ISLE()是用于数学计算的预定义函数。 数学H 是各种数学函数所需的头文件。 isless()函数用于检查给定给函数的第一个参数是否小于给定给函数的第二个参数。意味着如果 A. 第一个论点是 B 第二个参数是否检查 a 或者不是。 语法:
null
bool isless(a, b)
CPP
// CPP code to illustrate // the exception of function #include <bits/stdc++.h> using namespace std; int main() { // Take any values int a = 5; double b = nan( "1" ); bool result; // Since b value is NaN so // with any value of a, the function // always return false(0) result = isless(a, b); cout << a << " isless than " << b << ": " << result; return 0; } |
输出:
5 isless than nan: 0
例子:
- 节目:
CPP
// CPP code to illustrate
// the use of isless function
#include <bits/stdc++.h>
using
namespace
std;
int
main()
{
// Take two any values
int
a, b;
bool
result;
a = 5;
b = 8;
// Since 'a' is not greater
// than 'b' so answer
// is true(1)
result = isless(a, b);
cout << a <<
" isless than "
<< b
<<
": "
<< result << endl;
char
x =
'a'
;
// Since 'a' ascii value is less
// than b variable so answer
// is true(1)
result = isless(x, b);
cout << x <<
" isless than "
<< b
<<
": "
<< result;
return
0;
}
输出:
5 isless than 8: 1 a isless than 8: 0
注: 使用此函数,您还可以将任何数据类型与任何其他数据类型进行比较。 应用 在很多应用程序中,我们可以使用isless()函数比较两个值,比如在while循环中打印前9个自然数。
CPP
// CPP code to illustrate // the use of isless function #include <bits/stdc++.h> using namespace std; int main() { int i = 1; while (isless(i, 10)) { cout << i << " " ; i++; } return 0; } |
输出:
1 2 3 4 5 6 7 8 9
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END