Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
たとえば、score = UnixTimeOfNow() のようにスコアを生成する式がありますが、(1,100) のように (1,n) の範囲で最終的なスコアを取得したいと考えています。では、スコアを特定の範囲にマップするにはどうすればよいですか?
score範囲を含む値にマップするには、次の(1, n)ことができます。
score
(1, n)
score = 1 + (score % n);
(これはJava、C / C ++構文です。)
は%、たとえば205 % 100がであると言うモジュロ演算子です5。
%
205 % 100
5