Prev: Using (return val of) member function as default parameter of member function
Next: operator+() code for objects
From: mattia on 6 Nov 2009 09:03 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! ]
From: red floyd on 7 Nov 2009 07:24 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! ]
From: mattia on 7 Nov 2009 22:52 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! ]
From: red floyd on 8 Nov 2009 05:29 mattia wrote: > 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. > 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! ]
From: mattia on 8 Nov 2009 09:28
Il Sun, 08 Nov 2009 16:29:38 -0600, red floyd ha scritto: > mattia wrote: >> 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. >> >> > 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. 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! ] |