每日刷题(六十八)
ALGO-158、sign函数
#include<iostream>
#include<cmath>
using namespace std;
#define EPS 1e-6
int sign(double n)
{
if(fabs(n) <= EPS)
return 0;
else if(n < 0)
return -1;
else
return 1;
}
int main()
{
double x;
cin >> x;
cout << sign(x) << endl;
return 0;
}