Home > Net >  A great god can help me to solve this problem?
A great god can help me to solve this problem?

Time:09-20

Using c # double circulation mode?

CodePudding user response:

A loop can

Assume a var list=new array List () {1, 2, 5, 3, 2, 4, 6, 2, 21, 45}; Can be defined Dictionary Do, look at the code

 
Var numberList=new Dictionary (a);
The foreach (var temp in the list)
{
If (numberList. Either ContainsKey (temp))
{
NumberList [temp] + +;
}
The else
{
NumberList [\]=1;
}
}

Console. WriteLine (" mode of the existence of ");

Foreach (var temp in numberList. Where (pair=& gt; Pair. Value> (1). Select the pair=& gt; New {Number=pair. The Key, the Count=pair. The Value}) OrderByDescending (temp=& gt; Temp. Count))
{
Console. WriteLine (${temp. Number} "element occurrences {temp. Count}");
}



This article code on [making] (https://github.com/lindexi/lindexi_gd/tree/dd9092c538315c30f71526bc3c210d26be428f52/JekigaranekiferLaijolellecho) can copy all the code in your local running

CodePudding user response:

Tao is ready function its implementation can escape the cycle? Write their own use nested loop to better understand how to implement,
  •  Tags:  
  • C #
  • Related