You are required to build a system that can generate a random winning scenario for the T20 cricket world cup. There12 teams which will play knock-out matches in the first round. losing team is out and the winning team moves on. From the twelve teams, six winning teams will play another knock-out match. From these six teams, three winning teams will play against each other on the round robin basis (i.e. team A plays against team B, team B plays against team C, and team C plays against team A). The top two teams from this round will move to the final match. In case all the teams win one match each at this stage, then there will be a toss to move one team to the final while the other two teams will play against each other and the winner moves to the final. The winner of the final match is champion. generate random numbers for matches and toss You are required to use if-else (if-else-if) structure to run the tournament and generate one complete winning scenario randomly.
For generating a random number of matches, you can use the rand() function from std.
#include <iostream>
int main() {
for (int i = 0; i < std::rand(); i++) {
std::cout << std::rand() << std::endl;
}
return 0;
}
Comments
Leave a comment