<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Josephus Circle Help' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Josephus Circle Help' posted on the 'C and C++' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Fri, 24 May 2013 21:08:02 -0700</pubDate>
    <lastBuildDate>Fri, 24 May 2013 21:08:02 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Josephus Circle Help</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/346241/346241/josephus-circle-help/</link>
      <description>I've typed the program and all, but i just need help with changing the input to where my command line is like this:&lt;br /&gt;
&lt;br /&gt;
./a.out n m p&lt;br /&gt;
&lt;br /&gt;
n=number of players&lt;br /&gt;
&lt;br /&gt;
m=count used for every odd turn&lt;br /&gt;
&lt;br /&gt;
p= count used for every even turn&lt;br /&gt;
&lt;br /&gt;
help would be greatly appreciated thank you&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
here's the code:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
struct node {&lt;br /&gt;
        int key;&lt;br /&gt;
        node *next;};&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[]){&lt;br /&gt;
        if(argc &amp;gt;2) {&lt;br /&gt;
        int i, N = atoi(argv[1]), M = atoi(argv[2]);&lt;br /&gt;
        node *t, *x;&lt;br /&gt;
        t = new node;&lt;br /&gt;
        t-&amp;gt;key = 1;&lt;br /&gt;
        x = t;&lt;br /&gt;
        for(i = 2; i&amp;lt;=N; i++){&lt;br /&gt;
                t-&amp;gt;next = new node;&lt;br /&gt;
                t = t-&amp;gt;next;&lt;br /&gt;
                t-&amp;gt;key = i;&lt;br /&gt;
        }&lt;br /&gt;
        t-&amp;gt;next = x;&lt;br /&gt;
        while(t != t-&amp;gt;next){&lt;br /&gt;
                for(i = 1; i&amp;lt;M; i++)&lt;br /&gt;
                t = t-&amp;gt;next;&lt;br /&gt;
                cout &amp;lt;&amp;lt; t-&amp;gt;next-&amp;gt;key&amp;lt;&amp;lt;" ";&lt;br /&gt;
                x = t-&amp;gt;next;&lt;br /&gt;
                t-&amp;gt;next = x-&amp;gt;next;&lt;br /&gt;
                delete x;&lt;br /&gt;
        }&lt;br /&gt;
        cout &amp;lt;&amp;lt; t-&amp;gt;key &amp;lt;&amp;lt; endl;&lt;br /&gt;
        }&lt;br /&gt;
        return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/346241/346241/josephus-circle-help/</guid>
      <pubDate>Tue, 03 Oct 2006 21:24:01 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Josephus Circle Help</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/346241/346268/re-josephus-circle-help/#346268</link>
      <description>: I've typed the program and all, but i just need help with changing the input to where my command line is like this:&lt;br /&gt;
: &lt;br /&gt;
: ./a.out n m p&lt;br /&gt;
: &lt;br /&gt;
: n=number of players&lt;br /&gt;
: &lt;br /&gt;
: m=count used for every odd turn&lt;br /&gt;
: &lt;br /&gt;
: p= count used for every even turn&lt;br /&gt;
: &lt;br /&gt;
: help would be greatly appreciated thank you&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: here's the code:&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
: #include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
: using namespace std;&lt;br /&gt;
: &lt;br /&gt;
: struct node {&lt;br /&gt;
:         int key;&lt;br /&gt;
:         node *next;};&lt;br /&gt;
: &lt;br /&gt;
: int main(int argc, char* argv[]){&lt;br /&gt;
:         if(argc &amp;gt;2) {&lt;br /&gt;
:         int i, N = atoi(argv[1]), M = atoi(argv[2]);&lt;br /&gt;
:         node *t, *x;&lt;br /&gt;
:         t = new node;&lt;br /&gt;
:         t-&amp;gt;key = 1;&lt;br /&gt;
:         x = t;&lt;br /&gt;
:         for(i = 2; i&amp;lt;=N; i++){&lt;br /&gt;
:                 t-&amp;gt;next = new node;&lt;br /&gt;
:                 t = t-&amp;gt;next;&lt;br /&gt;
:                 t-&amp;gt;key = i;&lt;br /&gt;
:         }&lt;br /&gt;
:         t-&amp;gt;next = x;&lt;br /&gt;
:         while(t != t-&amp;gt;next){&lt;br /&gt;
:                 for(i = 1; i&amp;lt;M; i++)&lt;br /&gt;
:                 t = t-&amp;gt;next;&lt;br /&gt;
:                 cout &amp;lt;&amp;lt; t-&amp;gt;next-&amp;gt;key&amp;lt;&amp;lt;" ";&lt;br /&gt;
:                 x = t-&amp;gt;next;&lt;br /&gt;
:                 t-&amp;gt;next = x-&amp;gt;next;&lt;br /&gt;
:                 delete x;&lt;br /&gt;
:         }&lt;br /&gt;
:         cout &amp;lt;&amp;lt; t-&amp;gt;key &amp;lt;&amp;lt; endl;&lt;br /&gt;
:         }&lt;br /&gt;
:         return 0;&lt;br /&gt;
: }&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
Please, may you explain what the purpose of the program is? I do not know what Josephus Circle is.&lt;br /&gt;
&lt;br /&gt;
Steph&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/346241/346268/re-josephus-circle-help/#346268</guid>
      <pubDate>Wed, 04 Oct 2006 07:17:04 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Josephus Circle Help</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/346241/346297/re-josephus-circle-help/#346297</link>
      <description>: : I've typed the program and all, but i just need help with changing the input to where my command line is like this:&lt;br /&gt;
: : &lt;br /&gt;
: : ./a.out n m p&lt;br /&gt;
: : &lt;br /&gt;
: : n=number of players&lt;br /&gt;
: : &lt;br /&gt;
: : m=count used for every odd turn&lt;br /&gt;
: : &lt;br /&gt;
: : p= count used for every even turn&lt;br /&gt;
: : &lt;br /&gt;
: : help would be greatly appreciated thank you&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : here's the code:&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
: : #include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
: : using namespace std;&lt;br /&gt;
: : &lt;br /&gt;
: : struct node {&lt;br /&gt;
: :         int key;&lt;br /&gt;
: :         node *next;};&lt;br /&gt;
: : &lt;br /&gt;
: : int main(int argc, char* argv[]){&lt;br /&gt;
: :         if(argc &amp;gt;2) {&lt;br /&gt;
: :         int i, N = atoi(argv[1]), M = atoi(argv[2]);&lt;br /&gt;
: :         node *t, *x;&lt;br /&gt;
: :         t = new node;&lt;br /&gt;
: :         t-&amp;gt;key = 1;&lt;br /&gt;
: :         x = t;&lt;br /&gt;
: :         for(i = 2; i&amp;lt;=N; i++){&lt;br /&gt;
: :                 t-&amp;gt;next = new node;&lt;br /&gt;
: :                 t = t-&amp;gt;next;&lt;br /&gt;
: :                 t-&amp;gt;key = i;&lt;br /&gt;
: :         }&lt;br /&gt;
: :         t-&amp;gt;next = x;&lt;br /&gt;
: :         while(t != t-&amp;gt;next){&lt;br /&gt;
: :                 for(i = 1; i&amp;lt;M; i++)&lt;br /&gt;
: :                 t = t-&amp;gt;next;&lt;br /&gt;
: :                 cout &amp;lt;&amp;lt; t-&amp;gt;next-&amp;gt;key&amp;lt;&amp;lt;" ";&lt;br /&gt;
: :                 x = t-&amp;gt;next;&lt;br /&gt;
: :                 t-&amp;gt;next = x-&amp;gt;next;&lt;br /&gt;
: :                 delete x;&lt;br /&gt;
: :         }&lt;br /&gt;
: :         cout &amp;lt;&amp;lt; t-&amp;gt;key &amp;lt;&amp;lt; endl;&lt;br /&gt;
: :         }&lt;br /&gt;
: :         return 0;&lt;br /&gt;
: : }&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: Please, may you explain what the purpose of the program is? I do not know what Josephus Circle is.&lt;br /&gt;
: &lt;br /&gt;
: Steph&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
the purpose of this program is to simulate a game where there is a certain number players, and in each round a player is eliminated depending on the count. So if the count is 3 then every third person is eliminated&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/346241/346297/re-josephus-circle-help/#346297</guid>
      <pubDate>Wed, 04 Oct 2006 13:38:06 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Josephus Circle Help</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/346241/346301/re-josephus-circle-help/#346301</link>
      <description>: : : I've typed the program and all, but i just need help with changing the input to where my command line is like this:&lt;br /&gt;
: : : &lt;br /&gt;
: : : ./a.out n m p&lt;br /&gt;
: : : &lt;br /&gt;
: : : n=number of players&lt;br /&gt;
: : : &lt;br /&gt;
: : : m=count used for every odd turn&lt;br /&gt;
: : : &lt;br /&gt;
: : : p= count used for every even turn&lt;br /&gt;
: : : &lt;br /&gt;
: : : help would be greatly appreciated thank you&lt;br /&gt;
: : : &lt;br /&gt;
: : : &lt;br /&gt;
: : : here's the code:&lt;br /&gt;
: : : &lt;br /&gt;
: : : &lt;br /&gt;
: : : #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
: : : #include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
: : : using namespace std;&lt;br /&gt;
: : : &lt;br /&gt;
: : : struct node {&lt;br /&gt;
: : :         int key;&lt;br /&gt;
: : :         node *next;};&lt;br /&gt;
: : : &lt;br /&gt;
: : : int main(int argc, char* argv[]){&lt;br /&gt;
: : :         if(argc &amp;gt;2) {&lt;br /&gt;
: : :         int i, N = atoi(argv[1]), M = atoi(argv[2]);&lt;br /&gt;
: : :         node *t, *x;&lt;br /&gt;
: : :         t = new node;&lt;br /&gt;
: : :         t-&amp;gt;key = 1;&lt;br /&gt;
: : :         x = t;&lt;br /&gt;
: : :         for(i = 2; i&amp;lt;=N; i++){&lt;br /&gt;
: : :                 t-&amp;gt;next = new node;&lt;br /&gt;
: : :                 t = t-&amp;gt;next;&lt;br /&gt;
: : :                 t-&amp;gt;key = i;&lt;br /&gt;
: : :         }&lt;br /&gt;
: : :         t-&amp;gt;next = x;&lt;br /&gt;
: : :         while(t != t-&amp;gt;next){&lt;br /&gt;
: : :                 for(i = 1; i&amp;lt;M; i++)&lt;br /&gt;
: : :                 t = t-&amp;gt;next;&lt;br /&gt;
: : :                 cout &amp;lt;&amp;lt; t-&amp;gt;next-&amp;gt;key&amp;lt;&amp;lt;" ";&lt;br /&gt;
: : :                 x = t-&amp;gt;next;&lt;br /&gt;
: : :                 t-&amp;gt;next = x-&amp;gt;next;&lt;br /&gt;
: : :                 delete x;&lt;br /&gt;
: : :         }&lt;br /&gt;
: : :         cout &amp;lt;&amp;lt; t-&amp;gt;key &amp;lt;&amp;lt; endl;&lt;br /&gt;
: : :         }&lt;br /&gt;
: : :         return 0;&lt;br /&gt;
: : : }&lt;br /&gt;
: : : &lt;br /&gt;
: : : &lt;br /&gt;
: : Please, may you explain what the purpose of the program is? I do not know what Josephus Circle is.&lt;br /&gt;
: : &lt;br /&gt;
: : Steph&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: the purpose of this program is to simulate a game where there is a certain number players, and in each round a player is eliminated depending on the count. So if the count is 3 then every third person is eliminated&lt;br /&gt;
: &lt;br /&gt;
OK, thanks for the explanation. Here follows what I understood.&lt;br /&gt;
The program should create a circular linked list with each node containing 1,2,3,... up to the number of players. Is that right?&lt;br /&gt;
What I do not understand is who provides the count which indicates the players eliminated (3 in your example)? And what is the purpose of your m and p parameters?&lt;br /&gt;
May you be a bit clearer on what the program should do?&lt;br /&gt;
&lt;br /&gt;
Steph&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/346241/346301/re-josephus-circle-help/#346301</guid>
      <pubDate>Wed, 04 Oct 2006 14:39:34 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Josephus Circle Help</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/346241/346376/re-josephus-circle-help/#346376</link>
      <description>: : : : I've typed the program and all, but i just need help with changing the input to where my command line is like this:&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : ./a.out n m p&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : n=number of players&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : m=count used for every odd turn&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : p= count used for every even turn&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : help would be greatly appreciated thank you&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : &lt;br /&gt;
: : : : here's the code:&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : &lt;br /&gt;
: : : : #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
: : : : #include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
: : : : using namespace std;&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : struct node {&lt;br /&gt;
: : : :         int key;&lt;br /&gt;
: : : :         node *next;};&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : int main(int argc, char* argv[]){&lt;br /&gt;
: : : :         if(argc &amp;gt;2) {&lt;br /&gt;
: : : :         int i, N = atoi(argv[1]), M = atoi(argv[2]);&lt;br /&gt;
: : : :         node *t, *x;&lt;br /&gt;
: : : :         t = new node;&lt;br /&gt;
: : : :         t-&amp;gt;key = 1;&lt;br /&gt;
: : : :         x = t;&lt;br /&gt;
: : : :         for(i = 2; i&amp;lt;=N; i++){&lt;br /&gt;
: : : :                 t-&amp;gt;next = new node;&lt;br /&gt;
: : : :                 t = t-&amp;gt;next;&lt;br /&gt;
: : : :                 t-&amp;gt;key = i;&lt;br /&gt;
: : : :         }&lt;br /&gt;
: : : :         t-&amp;gt;next = x;&lt;br /&gt;
: : : :         while(t != t-&amp;gt;next){&lt;br /&gt;
: : : :                 for(i = 1; i&amp;lt;M; i++)&lt;br /&gt;
: : : :                 t = t-&amp;gt;next;&lt;br /&gt;
: : : :                 cout &amp;lt;&amp;lt; t-&amp;gt;next-&amp;gt;key&amp;lt;&amp;lt;" ";&lt;br /&gt;
: : : :                 x = t-&amp;gt;next;&lt;br /&gt;
: : : :                 t-&amp;gt;next = x-&amp;gt;next;&lt;br /&gt;
: : : :                 delete x;&lt;br /&gt;
: : : :         }&lt;br /&gt;
: : : :         cout &amp;lt;&amp;lt; t-&amp;gt;key &amp;lt;&amp;lt; endl;&lt;br /&gt;
: : : :         }&lt;br /&gt;
: : : :         return 0;&lt;br /&gt;
: : : : }&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : &lt;br /&gt;
: : : Please, may you explain what the purpose of the program is? I do not know what Josephus Circle is.&lt;br /&gt;
: : : &lt;br /&gt;
: : : Steph&lt;br /&gt;
: : : &lt;br /&gt;
: : &lt;br /&gt;
: : the purpose of this program is to simulate a game where there is a certain number players, and in each round a player is eliminated depending on the count. So if the count is 3 then every third person is eliminated&lt;br /&gt;
: : &lt;br /&gt;
: OK, thanks for the explanation. Here follows what I understood.&lt;br /&gt;
: The program should create a circular linked list with each node containing 1,2,3,... up to the number of players. Is that right?&lt;br /&gt;
: What I do not understand is who provides the count which indicates the players eliminated (3 in your example)? And what is the purpose of your m and p parameters?&lt;br /&gt;
: May you be a bit clearer on what the program should do?&lt;br /&gt;
: &lt;br /&gt;
: Steph&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ok in the code I provided N is the number of players and M is the count you use, they're both input in the command line for example:&lt;br /&gt;
&lt;br /&gt;
./a.out 7 3&lt;br /&gt;
&lt;br /&gt;
with 7 being the number of players and 3 being the count&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/346241/346376/re-josephus-circle-help/#346376</guid>
      <pubDate>Thu, 05 Oct 2006 19:47:33 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Josephus Circle Help</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/346241/346380/re-josephus-circle-help/#346380</link>
      <description>: : : : : I've typed the program and all, but i just need help with changing the input to where my command line is like this:&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : ./a.out n m p&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : n=number of players&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : m=count used for every odd turn&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : p= count used for every even turn&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : help would be greatly appreciated thank you&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : here's the code:&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
: : : : : #include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
: : : : : using namespace std;&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : struct node {&lt;br /&gt;
: : : : :         int key;&lt;br /&gt;
: : : : :         node *next;};&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : int main(int argc, char* argv[]){&lt;br /&gt;
: : : : :         if(argc &amp;gt;2) {&lt;br /&gt;
: : : : :         int i, N = atoi(argv[1]), M = atoi(argv[2]);&lt;br /&gt;
: : : : :         node *t, *x;&lt;br /&gt;
: : : : :         t = new node;&lt;br /&gt;
: : : : :         t-&amp;gt;key = 1;&lt;br /&gt;
: : : : :         x = t;&lt;br /&gt;
: : : : :         for(i = 2; i&amp;lt;=N; i++){&lt;br /&gt;
: : : : :                 t-&amp;gt;next = new node;&lt;br /&gt;
: : : : :                 t = t-&amp;gt;next;&lt;br /&gt;
: : : : :                 t-&amp;gt;key = i;&lt;br /&gt;
: : : : :         }&lt;br /&gt;
: : : : :         t-&amp;gt;next = x;&lt;br /&gt;
: : : : :         while(t != t-&amp;gt;next){&lt;br /&gt;
: : : : :                 for(i = 1; i&amp;lt;M; i++)&lt;br /&gt;
: : : : :                 t = t-&amp;gt;next;&lt;br /&gt;
: : : : :                 cout &amp;lt;&amp;lt; t-&amp;gt;next-&amp;gt;key&amp;lt;&amp;lt;" ";&lt;br /&gt;
: : : : :                 x = t-&amp;gt;next;&lt;br /&gt;
: : : : :                 t-&amp;gt;next = x-&amp;gt;next;&lt;br /&gt;
: : : : :                 delete x;&lt;br /&gt;
: : : : :         }&lt;br /&gt;
: : : : :         cout &amp;lt;&amp;lt; t-&amp;gt;key &amp;lt;&amp;lt; endl;&lt;br /&gt;
: : : : :         }&lt;br /&gt;
: : : : :         return 0;&lt;br /&gt;
: : : : : }&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : Please, may you explain what the purpose of the program is? I do not know what Josephus Circle is.&lt;br /&gt;
: : : : &lt;br /&gt;
: : : : Steph&lt;br /&gt;
: : : : &lt;br /&gt;
: : : &lt;br /&gt;
: : : the purpose of this program is to simulate a game where there is a certain number players, and in each round a player is eliminated depending on the count. So if the count is 3 then every third person is eliminated&lt;br /&gt;
: : : &lt;br /&gt;
: : OK, thanks for the explanation. Here follows what I understood.&lt;br /&gt;
: : The program should create a circular linked list with each node containing 1,2,3,... up to the number of players. Is that right?&lt;br /&gt;
: : What I do not understand is who provides the count which indicates the players eliminated (3 in your example)? And what is the purpose of your m and p parameters?&lt;br /&gt;
: : May you be a bit clearer on what the program should do?&lt;br /&gt;
: : &lt;br /&gt;
: : Steph&lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: ok in the code I provided N is the number of players and M is the count you use, they're both input in the command line for example:&lt;br /&gt;
: &lt;br /&gt;
: ./a.out 7 3&lt;br /&gt;
: &lt;br /&gt;
: with 7 being the number of players and 3 being the count&lt;br /&gt;
: &lt;br /&gt;
I cannot figure out what your problem is. At first sight, I don't see any mistake in your code, except the fact that you do not free the last node which remains after the while loop.&lt;br /&gt;
Here is an example of what I get:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
D:\Data\C\Temp&amp;gt;temp 7 3
3 6 2 7 5 1 4
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Isn't it what you want?&lt;br /&gt;
&lt;br /&gt;
Steph&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/346241/346380/re-josephus-circle-help/#346380</guid>
      <pubDate>Fri, 06 Oct 2006 03:24:14 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Josephus Circle Help</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/346241/347222/re-josephus-circle-help/#347222</link>
      <description>: : : : : : I've typed the program and all, but i just need help with changing the input to where my command line is like this:&lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : ./a.out n m p&lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : n=number of players&lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : m=count used for every odd turn&lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : p= count used for every even turn&lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : help would be greatly appreciated thank you&lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : here's the code:&lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
: : : : : : #include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
: : : : : : using namespace std;&lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : struct node {&lt;br /&gt;
: : : : : :         int key;&lt;br /&gt;
: : : : : :         node *next;};&lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : int main(int argc, char* argv[]){&lt;br /&gt;
: : : : : :         if(argc &amp;gt;2) {&lt;br /&gt;
: : : : : :         int i, N = atoi(argv[1]), M = atoi(argv[2]);&lt;br /&gt;
: : : : : :         node *t, *x;&lt;br /&gt;
: : : : : :         t = new node;&lt;br /&gt;
: : : : : :         t-&amp;gt;key = 1;&lt;br /&gt;
: : : : : :         x = t;&lt;br /&gt;
: : : : : :         for(i = 2; i&amp;lt;=N; i++){&lt;br /&gt;
: : : : : :                 t-&amp;gt;next = new node;&lt;br /&gt;
: : : : : :                 t = t-&amp;gt;next;&lt;br /&gt;
: : : : : :                 t-&amp;gt;key = i;&lt;br /&gt;
: : : : : :         }&lt;br /&gt;
: : : : : :         t-&amp;gt;next = x;&lt;br /&gt;
: : : : : :         while(t != t-&amp;gt;next){&lt;br /&gt;
: : : : : :                 for(i = 1; i&amp;lt;M; i++)&lt;br /&gt;
: : : : : :                 t = t-&amp;gt;next;&lt;br /&gt;
: : : : : :                 cout &amp;lt;&amp;lt; t-&amp;gt;next-&amp;gt;key&amp;lt;&amp;lt;" ";&lt;br /&gt;
: : : : : :                 x = t-&amp;gt;next;&lt;br /&gt;
: : : : : :                 t-&amp;gt;next = x-&amp;gt;next;&lt;br /&gt;
: : : : : :                 delete x;&lt;br /&gt;
: : : : : :         }&lt;br /&gt;
: : : : : :         cout &amp;lt;&amp;lt; t-&amp;gt;key &amp;lt;&amp;lt; endl;&lt;br /&gt;
: : : : : :         }&lt;br /&gt;
: : : : : :         return 0;&lt;br /&gt;
: : : : : : }&lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : : &lt;br /&gt;
: : : : : Please, may you explain what the purpose of the program is? I do not know what Josephus Circle is.&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : : Steph&lt;br /&gt;
: : : : : &lt;br /&gt;
: : : : &lt;br /&gt;
: : : : the purpose of this program is to simulate a game where there is a certain number players, and in each round a player is eliminated depending on the count. So if the count is 3 then every third person is eliminated&lt;br /&gt;
: : : : &lt;br /&gt;
: : : OK, thanks for the explanation. Here follows what I understood.&lt;br /&gt;
: : : The program should create a circular linked list with each node containing 1,2,3,... up to the number of players. Is that right?&lt;br /&gt;
: : : What I do not understand is who provides the count which indicates the players eliminated (3 in your example)? And what is the purpose of your m and p parameters?&lt;br /&gt;
: : : May you be a bit clearer on what the program should do?&lt;br /&gt;
: : : &lt;br /&gt;
: : : Steph&lt;br /&gt;
: : : &lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: : ok in the code I provided N is the number of players and M is the count you use, they're both input in the command line for example:&lt;br /&gt;
: : &lt;br /&gt;
: : ./a.out 7 3&lt;br /&gt;
: : &lt;br /&gt;
: : with 7 being the number of players and 3 being the count&lt;br /&gt;
: : &lt;br /&gt;
: I cannot figure out what your problem is. At first sight, I don't see any mistake in your code, except the fact that you do not free the last node which remains after the while loop.&lt;br /&gt;
: Here is an example of what I get:&lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
: D:\Data\C\Temp&amp;gt;temp 7 3
: 3 6 2 7 5 1 4
: &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: Isn't it what you want?&lt;br /&gt;
: &lt;br /&gt;
: Steph&lt;br /&gt;
: &lt;br /&gt;
sorry for long wait on the reply...but i finally got the code the way i needed it...appreciate the help though.&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/346241/347222/re-josephus-circle-help/#347222</guid>
      <pubDate>Thu, 19 Oct 2006 08:43:10 -0700</pubDate>
      <category>C and C++</category>
    </item>
  </channel>
</rss>