Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
help on round robin tournament
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
mattia  
View profile   Translate to Translated (View Original)
 More options 7 Nov, 02:03
Newsgroups: comp.lang.c++.moderated
From: mattia <ger...@gmail.com>
Date: Fri, 6 Nov 2009 20:03:06 CST
Local: Sat 7 Nov 2009 02:03
Subject: help on round robin tournament
I want to create a round robin tournament. The function receive a list
(I've used a deque) and for now just prints to stdout the results (e.g.
the round number and the schedule). If I wanted to provide the user a
data structure that has all the miningful informations, what do you
propose?

Here my code (I'm a C++ novice):

#include <iostream>
#include <deque>

int main(void)
{
    // games per team: n - 1
    std::deque<int> tournament;
    int c;
    int first = 0;
    // simple example with integers
    for (int i = 1; i < 8; i++)
    {
        tournament.push_back(i);
    }
    bool even = !(tournament.size() & 1);
    if (even)
    {
        first = tournament.front();
        tournament.pop_front();
    }
    for (int j = 0; j < tournament.size() - 1; j++)
    {
        std::cout << "Round " << j + 1 << ":" << std::endl;
        if (even)
        {
            std::cout << first << " vs " << tournament.back() <<
std::endl;
        }
        for (int i = 0; i < tournament.size()/2; i++)
        {
            std::cout << tournament[i] << " vs " << tournament
[tournament.size() - i - 2] << std::endl;
        }
        tournament.push_front(tournament.back());
        tournament.pop_back();
    }
    c = getchar();
    return 0;

}

Thanks, Mattia

--
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
red floyd  
View profile   Translate to Translated (View Original)
 More options 8 Nov, 00:24
Newsgroups: comp.lang.c++.moderated
From: red floyd <no.spam.h...@its.invalid>
Date: Sat, 7 Nov 2009 18:24:03 CST
Local: Sun 8 Nov 2009 00:24
Subject: Re: help on round robin tournament

mattia wrote:
> I want to create a round robin tournament. The function receive a list
> (I've used a deque) and for now just prints to stdout the results (e.g.
> the round number and the schedule). If I wanted to provide the user a
> data structure that has all the miningful informations, what do you
> propose?

> [redacted]

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2

--
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mattia  
View profile   Translate to Translated (View Original)
 More options 8 Nov, 15:52
Newsgroups: comp.lang.c++.moderated
From: mattia <ger...@gmail.com>
Date: Sun, 8 Nov 2009 09:52:58 CST
Local: Sun 8 Nov 2009 15:52
Subject: Re: help on round robin tournament
Il Sat, 07 Nov 2009 18:24:03 -0600, red floyd ha scritto:

> mattia wrote:
>> I want to create a round robin tournament. The function receive a list
>> (I've used a deque) and for now just prints to stdout the results (e.g.
>> the round number and the schedule). If I wanted to provide the user a
>> data structure that has all the miningful informations, what do you
>> propose?

>> [redacted]

> http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2

Well, I'm sorry you've misunderstood but I was asking for an advice, not
for homework (that I don't have since a long time ago). I've also said
that I'm a c++ novice, so I wated to know more about the OO programming
facing a simple problem that I was trying to solve.

--
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
red floyd  
View profile   Translate to Translated (View Original)
 More options 8 Nov, 22:29
Newsgroups: comp.lang.c++.moderated
From: red floyd <no.spam.h...@its.invalid>
Date: Sun, 8 Nov 2009 16:29:38 CST
Local: Sun 8 Nov 2009 22:29
Subject: Re: help on round robin tournament

Sorry.  Then you're better off asking in comp.algorithms.  There's
nothing C++ specific in your question, other than your use of a deque.

--
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mattia  
View profile   Translate to Translated (View Original)
 More options 9 Nov, 02:28
Newsgroups: comp.lang.c++.moderated
From: mattia <ger...@gmail.com>
Date: Sun, 8 Nov 2009 20:28:14 CST
Local: Mon 9 Nov 2009 02:28
Subject: Re: help on round robin tournament
Il Sun, 08 Nov 2009 16:29:38 -0600, red floyd ha scritto:

Well, I know no comp.algorithms newsgroup...

--
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google