我在C#中有一个彩票应用程序,其中包含要绘制的数字的数量以及要绘制的最大数量.我已编码为创建一个包含所需随机数的数组但我需要它们是唯一的并且我很难做到这一点如果有人能给我一些建议,我将非常感激,谢谢
到目前为止,这是我的代码:
class Lottery
{
static int[] numberHolder; //array to be filled with numbers up to an
//amount entered by the user eg 42 Max
static int[] drawHolder; //array to hold the each random number
//drawn from the pool of numbers eg 7 numbers
public Lottery() //Lottery class Constructor
{
}
//method which takes in a number limit and amount of numbers to be drawn
public String drawNumbers(int numLimit, int numAmount)
{
Random RandomNumber = new Random();
for (int i …
Run Code Online (Sandbox Code Playgroud) 我试图找出如何根据数组中是否存在String来为变量添加值.希望我的代码能够更好地解释它:
//calculate bonus
String[] department = {"Dublin","London","London","Dublin","Paris","Paris"};
int [] brokerTotal =(79,35,55,101,63,108};
int[] bonus;
bonus=new int[6];
for(int i = 0;i < department.length; i++) {
if (department ="Dublin") bonusRate=12;
else if (department="London") bonusRate=15;
else bonusRate=10;
bonus[i] = ((brokerTotal[i])/100)*bonusRate;
}
Run Code Online (Sandbox Code Playgroud)
if语句在这里抓住了我,我在这里关闭还是完全不合适?