用rand计算骰子的公式? [英] Calculating the formula of a dice roll using rand?

查看:93
本文介绍了用rand计算骰子的公式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!


所以,我正在使用模数和兰特作为我写作函数的一部分。现在,我理解:

Hi Guys!

So, I am using the modulus and a rand as part of a function I am writing. Now, I understand that:

展开 | 选择 | Wrap | 行号

推荐答案

我不知道是什么你的意思是常规算术因为模数是数学的一部分。


模数没有分数回报。是的,数字除以另一个数字可以返回一个分数。但那并不是模数的回报。模数只返回分数的分子,这是一个整数。


7/6 = 1和1/6。模数返回1.

8/6 = 1和2/6。模数返回2.

15/6 = 2和3/6。模数返回3.

等等。
I''m not sure what you mean by "regular" arithmetic because modulus is a part of math.

There is no fraction return by a modulus. Yes, a number divided by another number can return a fraction. But that''s not what a modulus returns. A modulus returns only the numerator of the fraction, and that is an integer.

7/6 = 1 and 1/6. The modulus returns 1.
8/6 = 1 and 2/6. The modulus returns 2.
15/6 = 2 and 3/6. The modulus returns 3.
And so on.


您好,

感谢您的回复!我目前正在使用math95和CS161,所以模数是常规数学的一部分对我来说是个新闻。我从来没有听说过它,直到CS161级。


无论如何,虽然你指出了这一点,但我仍然留下原来的问题。这听起来好像你基本上误解了它,考虑到我在一开始就试图表达我的担忧做了一份糟糕的工作,这并不难。我会试着更清楚。


所以,%b = a的剩余部分。我从一开始就已经知道了。我想问的是如何理解
Hi There,
Thanks for your reply! I am currently taking math95 along with CS161 so a modulus being a part of regular math is news to me. I never heard of it until mt CS161 class.

Anyway, although you pointed that out, I am still left with my original question. It sounds like you basically misunderstood it, that''s not a hard thing to do considering I did a poor job trying to articulating my concern in the first place. I''ll try to be more clear.

So, a % b = remainder of a. I already knew that from the start. What I was trying to ask was how do I make sense of
展开 | 选择 | Wrap | 行号


此代码:

This code:

展开 | 选择 | Wrap | 行号


这篇关于用rand计算骰子的公式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆