#include <iostream>
#include <cmath>
using namespace std;

/* wersja 1
int sgn(double x)
{
    if (x < 0)
        return -1;
    else if (x == 0)
        return 0;
    else
        return 1;
} */

/* wersja 2
int sgn(double x) // wersja 2
{
    return (x > 0)-(x < 0);
} */

/* wersja 3
int sgn(double x)
{
    return (x < 0)?-1:(x > 0)?1:0;
} */

/* wersja 4
int sgn(double x)
{
    if (x == 0)
        return 0;
    else
        (int)(return x/fabs(x));
} */

int sgn(double x) /* wersja 5 */
{
    return (x == 0)?0:(int)(x/fabs(x));
}

int main()
{
    double x = -5.67;
    cout << "sgn(" << x << ") = " << sgn(x) << endl;
    x = 0;
    cout << "sgn(" << x << ") = " << sgn(x) << endl;
    x = 23.78;
    cout << "sgn(" << x << ") = " << sgn(x) << endl;
    system("pause");
    return 0;
}