我有一個我想實作的異化模式,問題是我不擅長數學,我不知道如何去做,如何開始。
這是解釋:
0 to 31 result: 0
32 to 95 result: 36
96 to 159 result: 72
160 to 223 result: 108
224 to 287 result: 144
288 to 351 result: 180
352 to 415 result: 216
etc...
如果輸入數字小于 32,則始終回傳零。但如果輸入數字在 32 和 95 之間(包括 32 和 95),則回傳 36,以此類推所有塊。我認為這適用于 63 塊,結果增加了 36。
我應該如何對其進行編程以獲得這些結果?不確定是否有計算公式,因為最小輸入為 0,但最大輸入可能為 4294967295。
這是我目前擁有的代碼:
public static uint GetXboxAlignedNumber(uint inputValue)
{
uint alignedValue = 0;
if (inputValue < 32)
{
alignedValue = 0;
}
else
{
//Here goes the code
}
return alignedValue;
}
謝謝!!
uj5u.com熱心網友回復:
這應該作業
if (inputValue < 32)
{
return 0;
}
else
{
return (Math.Floor((inputValue - 32) / 64) 1) * 36;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/441736.html
