本文介绍了如何展示获胜者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有人可以帮助我展示这场乒乓球锦标赛的冠军。
I wonder if anyone can help me with showing the winner of this ping pong tournament.
她是鳕鱼
推荐答案
>>我想知道是否有人可以帮助我展示这场乒乓球锦标赛的冠军。
什么你的具体问题和逻辑是什么?我修改你的下面,希望能帮到你。
What are your specific questions and logic? I modify your below, hoping to help you.
Dictionary<int, string> winnerlisdic = new Dictionary<int, string>();
winnerlisdic.Add(0, "Peter");
winnerlisdic.Add(1, "Daniel");
winnerlisdic.Add(2, "Kim");
winnerlisdic.Add(3, "Philip");
winnerlisdic.Add(4, "Arild");
winnerlisdic.Add(5, "Junas");
winnerlisdic.Add(6, "Hans");
winnerlisdic.Add(7, "Hugo");
winnerlisdic.Add(8, "Linus");
winnerlisdic.Add(9, "Simon");
winnerlisdic.Add(10, "Johan");
winnerlisdic.Add(11, "Sigurd");
winnerlisdic.Add(12, "Robert");
winnerlisdic.Add(13, "Karl");
winnerlisdic.Add(14, "Erik");
winnerlisdic.Add(15, "Martin");
winnerlisdic.Add(16, "Isac");
winnerlisdic.Add(17, "Isak");
winnerlisdic.Add(18, "Pakorn");
winnerlisdic.Add(19, "Nils");
int[] tävlande = new int[20] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
Console.WriteLine("\n De tävlande fick följande poäng: \n");
Random rnd = new Random();
for (int x = 0; x < 20; x++)
{
for (int i = 0; i < 20; i++)
{
int p = rnd.Next(3);
if (p == 0)
tävlande[x] += 20;
else if (p == 1)
tävlande[x] += 10;
}
Console.WriteLine(tävlande[x]);
}
var v = tävlande.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).Take(1).ToList()[0];
var WinnerO = winnerlisdic.FirstOrDefault(q => q.Key == v.index).Value;
MessageBox.Show("Vinnaren hadde: " + WinnerO + " !, Score: "+ v.m);
$
如果我有任何误解,您可以包含所有必要的代码其他任何人都可以从头开始重现您的问题以及有关结果的详细说明,包括任何异常消息。
If I have any misunderstanding, you can include all necessary code snippets for anyone else to be able to reproduce your issue from scratch along with a detailed description about the results including any exception messages.
最好的问候,
Yohann Lu
Yohann Lu
这篇关于如何展示获胜者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!