Question

I need to create a C++ program to simulate a Round Robin Tournament. For example: if...

I need to create a C++ program to simulate a Round Robin Tournament.

For example: if a user enters 4, a 4 team tournament would output:

1 2 3 4

2 1 4 3

3 4 1 2

4 3 2 1

My goal is to create this program using a two dimentional array, however I am unsure how to go about doing initializing everything. How do I write a constructor for this? The following is the class declaration I must use, things can be added, but nothing can be removed from it.


class Scheduler
{
public:
Scheduler(); // default constructor
Scheduler(int ini_teams); // constructor
// generate the schedule for the number of team = teams
void generateSchedule();

// display the table content of the schedule for each team
void print();
// destructor
~Scheduler();
int check();
// more member functions here ...
private:
int teams; // the number of teams to be scheduled
int** Arrange;
// the two dimensional vector to represent the
// scheduling table for each team
};

Any help would be greatly appreciated.

An 8 team tournament would output:

1 2 3 4 5 6 7 8
2 1 4 3 6 5 8 7
3 4 1 2 7 8 5 6
4 3 2 1 8 7 6 5
5 6 7 8 1 2 3 4
6 5 8 7 2 1 4 3
7 8 5 6 3 4 1 2
8 7 6 5 4 3 2 1

The schedule for 16 teams:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15
3 4 1 2 7 8 5 6 11 12 9 10 15 16 13 14
4 3 2 1 8 7 6 5 12 11 10 9 16 15 14 13
5 6 7 8 1 2 3 4 13 14 15 16 9 10 11 12
6 5 8 7 2 1 4 3 14 13 16 15 10 9 12 11
7 8 5 6 3 4 1 2 15 16 13 14 11 12 9 10
8 7 6 5 4 3 2 1 16 15 14 13 12 11 10 9
9 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8
10 9 12 11 14 13 16 15 2 1 4 3 6 5 8 7
11 12 9 10 15 16 13 14 3 4 1 2 7 8 5 6
12 11 10 9 16 15 14 13 4 3 2 1 8 7 6 5
13 14 15 16 9 10 11 12 5 6 7 8 1 2 3 4
14 13 16 15 10 9 12 11 6 5 8 7 2 1 4 3
15 16 13 14 11 12 9 10 7 8 5 6 3 4 1 2
16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
I need to create a C++ program to simulate a Round Robin Tournament. For example: if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • This needs to be in C++ Problem3.cpp Problem3.h: Given a matrix, clockwise-rotate elements in it. Please...

    This needs to be in C++ Problem3.cpp Problem3.h: Given a matrix, clockwise-rotate elements in it. Please add the code to problem3.h and problem3.cpp, provided. Input 4 Output: 1 8 For 4*4 matrix Input: 4 7 9 10 11 12 13 14 15 16 Output: 9 10 6 4 13 11 7 8 14 15 16 12 #include "problem3.h" 2 3 void rotatematrix(int m, int n, int mat[][MAX]) 4 //write your code here 5 1 #ifndet LAB3 PROBLEM3 2 #define LAB3PROBLEM3...

  • Five processes arrive to run on a CPU. The scheduler puts them in its data structure....

    Five processes arrive to run on a CPU. The scheduler puts them in its data structure. The table below lists the processes, how much CPU time each will need, and the priority of each process. One(1) is the highest priority and 4 is the lowest priority. Process CPU time needed Priority P1 P2 P3 NNW-W a. The scheduler uses First Come First Serve to schedule the jobs. Fill in the time line below showing at what time each process starts...

  • For C++ Write a program that randomly generates 100 integers and sorts them using radix sort....

    For C++ Write a program that randomly generates 100 integers and sorts them using radix sort. Note: Your output would not be the same as this sample output due to the randomness. Sample output: 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 4 4 4 4 4 4 4 4 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7...

  • I need some help with this question. Create a table of values and an associated graph...

    I need some help with this question. Create a table of values and an associated graph that are concave up twice and concave down once. y 1 3 2 3 3 4 7 5 12 6 14 7 15 8 14 9 11 10 6 11 3 12 2 13 14 7 15 13

  • I have a table that looks like this. 1234 5678 9101112 I need to use this...

    I have a table that looks like this. 1234 5678 9101112 I need to use this code public class Lab8 { public static void main(String argv[]) { int ar[][] = new int[3][4]; int n = 1; for (int i=0; i < ar.length; i++) { for (int j=0; j< ar[i].length; j++) { ar[i][j] = n; n++; } } // print out the elements of the array // left to right, top to bottom for (int i=0; i < ar.length; i++) {...

  • I posted this question earlier but realized that the code was not easy to test since...

    I posted this question earlier but realized that the code was not easy to test since it was just screenshots and not text so I am reposting it: I'm very new at working with file streams, and I'm having trouble with a HW assignment I have to work on. For the assignment I have to read an input file named "MagicSquaresIn.txt" (included at the bottom) and I have to check whether they are normal, associative, and panmagic. To check that...

  • A group of 10 friends are playing a game of guessing the outcome of a tournament...

    A group of 10 friends are playing a game of guessing the outcome of a tournament played among 8 teams (labeled team 1 to team 8) with a fixed schedule as follows. In round 1, team 1 plays against teams 2, team 3 plays against team 4, team 5 plays against team 6, and team 7 plays against team 8. In round 2, the winner of (1,2) plays against the winner of (3,4), the winner of (5,6) plays against the...

  • Problem 6. The set (Z19 − {0}, ·19) is a group with the indicated operation; see...

    Problem 6. The set (Z19 − {0}, ·19) is a group with the indicated operation; see the attached table. a.) Show that H = {1, 7, 8, 11, 12, 18} is a subgroup. b.) List all the right cosets of H. c.) Show that if Hy = Hx then xy−1 ∈ H. [Make sure to give a reason for each step.] d.) Show that φ : H → Hx defined by φ(h) = hx is one-to-one and onto. [Use the...

  • This question has been answered before, but no codes given as the answer were right. please...

    This question has been answered before, but no codes given as the answer were right. please help. In the mathematical theory of sets, a set is defined as a collection of distinct items of the same type. In some programming languages, sets are built-in data types; unfortunately, this is not the case in C++. However, we can simulate a set using a one-dimensional array. Some operations can be performed on sets. We will consider three(3) of them: union, intersection and...

  • C++ how can I fix these errors this is my code main.cpp #include "SpecialArray.h" #include <...

    C++ how can I fix these errors this is my code main.cpp #include "SpecialArray.h" #include <iostream> #include <fstream> #include <string> using namespace std; int measureElementsPerLine(ifstream& inFile) {    // Add your code here.    string line;    getline(inFile, line);    int sp = 0;    for (int i = 0; i < line.size(); i++)    {        if (line[i] == ' ')            sp++;    }    sp++;    return sp; } int measureLines(ifstream& inFile) {    // Add your code here.    string line;    int n = 0;    while (!inFile.eof())    {        getline(inFile,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT