GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 10-Jul-2008, 06:46
Evilrock Evilrock is offline
New Member
 
Join Date: Jul 2008
Posts: 1
Evilrock is on a distinguished road

C++ Nested loop coding


Please help me with this.
i want to write a program to accept the number of digits from the user and then print all the combinations possible in that number of digits. the combinations should not repeat the particular number twice.
for example: if a users inputs 3 then the program shud print all possible combinations in 3 digit numbers ==> 123,456,789,124,125..... without repeating the number like==>111,112,211,221.
Please help me out with this as soon as possible.
thank you
  #2  
Old 10-Jul-2008, 08:49
ocicat ocicat is offline
Regular Member
 
Join Date: May 2008
Posts: 580
ocicat is a jewel in the roughocicat is a jewel in the rough

Re: C++ Nested loop coding ...plz help


Quote:
Originally Posted by Evilrock
Please help me out with this as soon as possible.
We can be quite forthcoming with suggestions, corrections, & insight if if it is clear that you have already put in effort to solve the problem. Otherwise, it can appear that you are simply dropping off homework assignments waiting for us to do the work for you.

You will learn more if you attempt the problem first.

Posting code also provides a great starting point for discussion as this helps frame what topics you seek clarification.
  #3  
Old 10-Jul-2008, 10:45
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 713
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: C++ Nested loop coding ...plz help


Here is a routine that would print for input of 3. You will be required to change it to print for any number of digits.

CPP / C++ / C Code:
void PrintAllCombinationsOf3Digits()
{ int i,j,k;
  
  for(i=0;i<10;++i)
  { 
    for(j=0;j<10;++j)
    {
      for(k=0;k<10;++k)
      { 
        // Skip the repeaters
        if(i == j || i == k || j == k) continue;

        // Print the digits
        cout << i << j << k << endl;
      }
    }
  }
}
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classic recursion game of 8 Queens errors BKizzle77 Java Forum 11 11-Aug-2008 01:35
Having problems making nested loop add4390 Java Forum 3 27-Nov-2007 09:48
Nested For Loop thread dragon71 C++ Forum 1 16-Apr-2007 20:03
Nested for loop with function Tori C++ Forum 11 08-Nov-2004 14:02
coding a sentinel controlled loop tommy69 C++ Forum 2 10-Mar-2004 15:52

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:50.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.