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.
For every match, you can generate a random number to declare the winner of the match. Similarly, you
can use a random number to simulate the toss. You are required to use if-else (if-else-if) structure to run
#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;
}
Comments
Leave a comment