Why is this case it is random is there any way to improve it? For teachers to give directions!
CodePudding user response:
Why 1 -- will come? Your vote is certainly more and more, how can I -???CodePudding user response:
Oh, read the problem is in the wrong and ar_banzhang [I]=1CodePudding user response:
Not with five run that you define a collection all the generated random number is saved, then define the howling XX howling * * 2, 1 finished 30 cycle, direct statistics in 1, 2, 3, 4, 5 how much is okCodePudding user response:
The initialization of an array in a whileCodePudding user response:
Have considered the feelings of liu?CodePudding user response:
Find the position of the largest number in an array (subscript) is the Aggregate programming mode, the first records the first subscript results for the initial hypothesis, then loop all the subscript, if a larger Numbers to replace the record,var arr=new int [] {1, 5, 2, 3, 8};
Var r=Enumerable. Range (0, arr. Length). The Aggregate (new
{
The subscript=0,
The maximum=arr [0]
}, (res, index)=& gt;
{
Var v=arr [index];
If (v & gt; Res. The maximum)
The return of new
{
The subscript=index,
The maximum=v
};
The else
return res;
});
The Debug. Assert (r. subscript==4);
CodePudding user response:
Colleagues var data=https://bbs.csdn.net/topics/new string [] {" A "and" colleagues "B, C" colleagues ", "D" colleagues, colleagues "E"};
Var res=new List(a);
For (var I=0; i <30; I++)
{
Var randomBytes=new byte [4];
Var rngServiceProvider=new RNGCryptoServiceProvider ();
RngServiceProvider. GetBytes (randomBytes);
Var result=Math. Abs (BitConverter ToInt32 (randomBytes, 0)) % 5 + 1;
Res. The Add (result);
}
Var group=res. GroupBy (x=& gt; x);
Var maxValue=https://bbs.csdn.net/topics/group.Max (y=> y.C mount ());
The foreach (var row in group)
{
Console. WriteLine (${data "[row. The Key - 1]} player vote {row. The Count ()}");
}
Foreach (var row in the group. The Where (y=& gt; Y.C mount ()==maxValue))
{
Console. WriteLine (${data "[row. The Key - 1]} player got the highest vote {row. The Count ()}");
}
CodePudding user response:
I found that as long as it is a flat ticket will appear bug, could you tell me if there is a flat ticket, how to deal with to make the system to vote,