[英]how can I get an conditional output?
我有兩個整數(輸入和 output)
when input >= 1 and <= 100000 , output will 20
when input >= 100001 and <= 200000 , output will 30
when input >= 200001 and <= 300000 , output will 40
when input >= 300001 and <= 400000 , output will 50
when input >= 400001 and <= 500000 , output will 60
...
...
and so on.
最大輸入范圍無限制
如何在 C# 中管理它
output = (ceil(input/100000) +1)*10
ceil function 基本上在浮點數上方四舍五入到 integer。
簡單的算術以及 integer 除法應該可以解決問題
var output = (input / 100000) * 10 + 20;
如果input
已經是浮點數或小數,則使用Math.Floor
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.