//Judging the winning situation Public voidZhongjiangqingkuang (intnum) { if(num>=4) {Console.Write ("congratulations on your winning."); if(num = =6) {Console.Write ("Grand Prize, million bonus take home"); } if(num = =5) {Console.Write ("First prize, Million dollar bonus take home"); } Else if(num = =4) {Console.Write ("thousand dollar bonus take home"); } } Else{Console.Write ("Kaejinn, welcome back."); } }
Public int[] Shuru () {int[] Haoma=New int[7]; Try{Console.WriteLine ("Enter the red ball number you want to select:"); for(inti =0; I <6; i++) {Console.Write ("Section"+ (i+1)+"the number of balls is:"); Haoma[i]=int. Parse (Console.ReadLine ()); } console.write ("Enter the blue ball number you want to select:"); intA =int. Parse (Console.ReadLine ()); haoma[6] =A; } Catch(Exception ex) {Console.WriteLine ("There is an error, the error content is"+Ex. Message); } returnHaoma; }
Output Ball Number
public void Shuchu (Int[]shuzu)
{
for (int i = 0; i < Shuzu. length;i++)
{
Console.Write (shuzu[i]+ "");
}
}
//get the same number of balloons Public intPanduan (int[] shuzu1,int[] SHUZU2,int[] shuzu3) { intnum=0; if(SHUZU1[SHUZU1. length-1]==shuzu3[shuzu3. length-1]) {num++; } for(inti =0; I < SHUZU1. length-1; i++ ) { for(intj =0; J < Shuzu2. length;j++ ) { if(Shuzu2[j] = =Shuzu1[i]) {num++; } } } returnnum; }
//randomly produce different ball numbers. Public int[] Getrandomnum (intNumintMinValue,intmaxValue) {Random ra=NewRandom (unchecked((int) (DateTime.Now.Ticks)) ; int[] Arrnum =New int[num]; intTMP =0; for(inti =0; I <= Num-1; i++) {tmp= ra. Next (MinValue, MaxValue);//Random Fetch numberArrnum[i] = Getnum (Arrnum, TMP, MinValue, MaxValue, RA);//The value of the fetch is assigned to the array } //int b = ra. Next (16); //arrnum[num-1] = b; returnArrnum; } Public intGetnum (int[] Arrnum,intTmpintMinValue,intMaxValue, Random RA) { intn =0; while(N <= arrnum.length-1) { if(Arrnum[n] = = tmp)//use loops to determine if there are duplicates{tmp= ra. Next (MinValue, MaxValue);//re-randomly acquired. Getnum (Arrnum, TMP, MinValue, MaxValue, RA);//recursion: If the extracted number and the obtained number are duplicated, they are retrieved randomly. } n++; } returntmp; } }
Shuangseqiu Shu =NewShuangseqiu (); //Get input number int[] qiuhao=Shu. Shuru (); Console.Write ("your number is:"); Shu.shuchu (Qiuhao); //generate red Winning numbers int[] redarr= Shu.getrandomnum (6,1, -); Console.WriteLine ("The red winning numbers are:"); Shu.shuchu (Redarr); //generate blue Winning numbers int[] Bluearr = Shu.getrandomnum (1,1, -); Console.WriteLine ("The Blue winning numbers are:"); Shu.shuchu (Bluearr); //int[] Zhongjiangnum = Shu.zhongjianghao (Redarr,bluearr); //Console.WriteLine ("Winning number is:"); //Shu.shuchu (Zhongjiangnum); //Compare equal numbers intno=Shu. Panduan (Qiuhao,redarr,bluearr); Console.Write ("the same number is:"+no); Shu.zhongjiangqingkuang (no); Console.ReadLine ();
Color Ball (Array implementation)