2011年12月11日 星期日

Create Random Number Sequence with No Repeats

ArrayList arraylist = new ArrayList();
int a;
while (arraylist.Count < 8)
{
    a = rand.Next(0, 9);
    if (!arraylist.Contains(a))
    {
        arraylist.Add(a);
    }
}

2011年11月23日 星期三

Recursion

private void beeColony_Load(object sender, EventArgs e)
{
    n = Convert.ToInt16(textBox6.Text);
    n = recursion(n);
}

public int recursion(int n) //遞迴算出總共有幾條路徑
{
    if (n <= 1)
    {
        return 1;
    }
    else
    {
        return n * recursion(n - 1);
    }
}