A function to return a sign

前端 未结 8 1291
春和景丽
春和景丽 2021-01-17 08:40

I know this will really turn out to be simple, but my brain is just not working. I need a function in C# that will return -1 if the integer passed to the function has a nega

8条回答
  •  一整个雨季
    2021-01-17 09:14

    public int SignFunction( int input )
    {
        if( input < 0 ) return -1;
        if( input > 0 ) return 1;
        return 0;
    }
    

提交回复
热议问题