Answer to Question #262229 in C++ for saliha

Question #262229

this problem, you are required to build a system that can generate a random winning


scenario for the T20 cricket world cup. There are 12 teams in the tournament and every team will play


one match each on the knock-out basis in the first round. It means that the losing team of every match


leaves the tournament while the winning team continues to play the next match. 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 will be declared the champion of the T20 world cup.

1
Expert's answer
2021-11-07T10:15:38-0500
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
 static void getSix(int *dst){
 int sz,pos,i,src[12];
 for(i=0;i<sizeof(src)/sizeof(*src);i++){
    src[i]=i+1;
 sz=12;
 for(i=0;i<6;i++){
    pos=rand()%sz;
    dst[i]=src[pos];
    src[pos]=src[sz-1];
    sz--;
    for(i=0;i<3;i++){
    pos=rand()%sz;
    dst[i]=src[pos];
    src[pos]=src[sz-1];
    sz--;}
 }
 }
 }


int main(void){
    srand(time (NULL));
    int i,teams[6];
    getSix(teams);
    cout<<"Numbers:\n";
    for(i=0;i=sizeof(teams)/sizeof(*teams);i++){
        cout<<"Teams: "<<teams[i]<<endl;
        for(i=0;i=sizeof(teams)/sizeof(*teams);i++){
        cout<<"teams: "<<teams[i]<<endl;
    }}
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS