如何让用户创建多个骰子?

时间:2015-06-02 17:50:42

标签: c#

所以现在,这段代码只能让你骰子十次,但如果我想让用户输入任意数量的骰子,我该怎么做?

static void Main(string[] args)
    {

        Random numgen = new Random();
        int dice1 = 0;
        int dice2 = 1;

        for (int roll = 0; roll <=10; roll++)
        {
            dice1 = numgen.Next(1,7);
            dice2 = numgen.Next(1,7);
            Console.WriteLine(dice1 + "\t" + dice2);
        }

        Console.ReadLine();


    }

1 个答案:

答案 0 :(得分:0)

因为看起来你似乎不需要保存任何骰子,而只是将它们输出到屏幕上,我会省略骰子。

redblue_number(Nr) :-
   a(Nr, red),
   a(Nr, blue).

nr_related(Nr, Related) :-
   redblue_number(Nr),
   dif(Related, red),
   dif(Related, blue),
   a(Nr, Related).

?- nr_related(Nr, Related).
Nr = 1,
Related = green ;
Nr = 4,
Related = green ;
Nr = 4,
Related = purple ;
false.