这个 是无序的 函数在中定义
null
语法:
bool isunordered(float x, float y);
或
bool isunordered(double x, double y);
参数: 需要 两个值x和y i、 e值以检查它们是否无序。
返回: 它回来了 1. 如果x或y的值为NAN,则返回NAN 0 .
下面的程序演示了C++中的isunordered()函数:
例1:-
// c++ program to demonstrate // example of isunordered() function. #include <bits/stdc++.h> using namespace std; int main() { float x=6.3; float y= sqrt (-9); cout<< "The value of x is= " << x << endl; cout<< "The value of y is= " << y << endl; //Now it return whether x or y are unordered values or not cout<< "isunordered(x, y) = " <<isunordered(x, y); return 0; } |
输出:
The value of x is= 6.3 The value of y is= -nan isunordered(x, y) = 1
说明: 在示例1中,y的值为NAN,这就是函数返回1的原因。
例2:-
// c++ program to demonstrate // example of isunordered() function. #include <bits/stdc++.h> using namespace std; int main() { float x=4.6; float y=9.2; cout<< "The value of x is= " << x << endl; cout<< "The value of y is= " << y << endl; //Now it return whether x or y are unordered values or not cout<< "isunordered(x, y) = " <<isunordered(x, y); return 0; } |
输出:
The value of x is= 4.6 The value of y is= 9.2 isunordered(x, y) = 0
说明: 在示例2中,x和y的值不是NAN,这就是函数返回0的原因。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END