Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void Rennazin()
- {
- var listaDeParticipantes = new List<dynamic>
- {
- new
- {
- Nome = "Turma da Cerveja",
- Pontuacao = 8000.0
- },
- new
- {
- Nome = "Turma da LG",
- Pontuacao = 10000.0
- },
- new
- {
- Nome = "Turma da Caaa",
- Pontuacao = 4000.0
- },
- new
- {
- Nome = "Turma da LGddsds",
- Pontuacao = 89500.0
- },
- new
- {
- Nome = "Turma da Cerveja",
- Pontuacao = 4000.0
- },
- new
- {
- Nome = "Turma da LG",
- Pontuacao = 20000.0
- },
- new
- {
- Nome = "Turma da Caaa",
- Pontuacao = 6000.0
- },
- new
- {
- Nome = "Turma da LGddsds",
- Pontuacao = 89000.0
- }
- };
- listaDeParticipantes = listaDeParticipantes.OrderBy(x => x.Nome).ToList();
- while (listaDeParticipantes.Count > 2)
- {
- listaDeParticipantes = Processo(listaDeParticipantes);
- }
- var vencedores = listaDeParticipantes.OrderByDescending(x => x.Pontuacao).ToList();
- }
- private static List<dynamic> Processo(List<dynamic> listaDeParticipantes)
- {
- var listaDeVencedores = new List<dynamic>();
- var quantidadeDeTimes = listaDeParticipantes.Count;
- for (int i = 0; i < quantidadeDeTimes / 2; i++)
- {
- listaDeVencedores.Add(ObtenhaVencedor(listaDeParticipantes[i], listaDeParticipantes[quantidadeDeTimes - i - 1]));
- }
- return listaDeVencedores;
- }
- public static dynamic ObtenhaVencedor(dynamic a, dynamic b)
- {
- return a.Pontuacao < b.Pontuacao ? b : a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement