小问题 [英] Little Problem

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

问题描述

我有三个号码 - 1,2和& 3.


三个中随机选择的一个存储在''var1''中,另一个

随机选择一个存储在''var2''中。


如何找出遗留的数字?


我尝试了一段时间但我无法得到它工作......


TIA

I have three numbers - 1, 2 & 3.

A randomly selected one of the three are stored in ''var1'', and another
randomly selected one is in ''var2''.

How do I find out the number that is left over?

I tried a while loop but I couldn''t get it to work...

TIA

推荐答案

fsd,


我要做的是将值存储在ArrayList中。当你随机选择

数字时,将它们从ArrayList中删除并放入一个新的

集合中。这将要求您每次更改所选随机

数字的范围(第一次从范围中选择随机数

1-3,然后1-2等等)。当你有足够的

数字时,你必须停下来。然后,在ArrayList中留下的是什么是

未被选中。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv * @ spam。 guard.caspershouse.com


" fsd" < sg@hotmial.com>在留言中写道

news:bs ************ @ ID-83837.news.uni-berlin.de ...
fsd,

What I would do is store the values in an ArrayList. When you pick the
numbers randomly, remove them from the ArrayList and place into a new
collection. This would require you to change the range of selected random
numbers every time (the first time you pick a random number from the range
1-3, then 1-2, etc, etc). You just have to stop when you have enough
numbers selected. Then, whatever is left over in the ArrayList is what was
not selected.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"fsd" <sg@hotmial.com> wrote in message
news:bs************@ID-83837.news.uni-berlin.de...
I有三个数字 - 1,2和& 3.

随机选择的三个存储在''var1''中,另一个随机选择的存储在''var2''中。
我如何找出剩余的数字?

我尝试了一段时间但我无法让它工作......

TIA
I have three numbers - 1, 2 & 3.

A randomly selected one of the three are stored in ''var1'', and another
randomly selected one is in ''var2''.

How do I find out the number that is left over?

I tried a while loop but I couldn''t get it to work...

TIA



这样的东西(伪代码):


var1 = Random(3);

var2 =随机(3);

而(var2 == var1)

{

var2 =随机( 3);

}


-

Dmitriy Lapshin [C#/ .NET MVP]

X-Unity Test Studio
http:// x- unity.miik.com.ua/teststudio.aspx

将单元测试的强大功能带到VS .NET IDE


" fsd" < sg@hotmial.com>在留言中写道

news:bs ************ @ ID-83837.news.uni-berlin.de ...
Something like this (pseudo-code):

var1 = Random(3);
var2 = Random(3);
while (var2 == var1)
{
var2 = Random(3);
}

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"fsd" <sg@hotmial.com> wrote in message
news:bs************@ID-83837.news.uni-berlin.de...
I有三个数字 - 1,2和& 3.

随机选择的三个存储在''var1''中,另一个随机选择的存储在''var2''中。
我如何找出剩余的数字?

我尝试了一段时间但我无法让它工作......

TIA
I have three numbers - 1, 2 & 3.

A randomly selected one of the three are stored in ''var1'', and another
randomly selected one is in ''var2''.

How do I find out the number that is left over?

I tried a while loop but I couldn''t get it to work...

TIA






fsd写道:
我有三个数字 - 1,2和& 3.

随机选择的三个存储在''var1''中,另一个随机选择的存储在''var2''中。
我如何找出剩余的数字?

我尝试了一段时间但我无法让它工作......

TIA
I have three numbers - 1, 2 & 3.

A randomly selected one of the three are stored in ''var1'', and another
randomly selected one is in ''var2''.

How do I find out the number that is left over?

I tried a while loop but I couldn''t get it to work...

TIA




一起添加var1和var2


伪代码;


开关(var1 + var2)

案例3:剩下三个

案例4:剩下两个

案例5:一个是左



Add var1 and var2 together

psuedo code;

switch(var1 + var2)
case 3: three is left
case 4: two is left
case 5: one is left


这篇关于小问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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