A tournament features 128 teams, and each match is a knockout match.
Jignesh Kumar
Select an image from your device to upload
Write a program to determine the winner of a tournament and calculate the total number of matches required to identify the winner?
The article presents an interesting tournament scenario where strategy and knockout matches create exciting competition. After reading content like this, I enjoy Meccha Chameleon Game which is a colorful challenge with clever moves and quick reactions.
using System;
class Tournament{ public static void Main() { int totalTeams = 128; // Initial number of teams int totalMatches = totalTeams - 1; // Number of matches = teams - 1
Console.WriteLine("Total matches played in the tournament: " + totalMatches); // Simulate the rounds int round = 1; int teamsInCurrentRound = totalTeams; while (teamsInCurrentRound > 1) { int matchesInCurrentRound = teamsInCurrentRound / 2; Console.WriteLine($"Round {round}: {matchesInCurrentRound} matches"); // Half of the teams are eliminated in each round teamsInCurrentRound /= 2; round++; }}
Console.WriteLine("Total matches played in the tournament: " + totalMatches);
// Simulate the rounds
int round = 1;
int teamsInCurrentRound = totalTeams;
while (teamsInCurrentRound > 1)
{
int matchesInCurrentRound = teamsInCurrentRound / 2;
Console.WriteLine($"Round {round}: {matchesInCurrentRound} matches");
// Half of the teams are eliminated in each round
teamsInCurrentRound /= 2;
round++;
}
Example Output:Total matches played in the tournament: 127Round 1: 64 matchesRound 2: 32 matchesRound 3: 16 matchesRound 4: 8 matchesRound 5: 4 matchesRound 6: 2 matchesRound 7: 1 matches