Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: help needed in generating all combinations of 8 numbers  (Read 3275 times)

0 Members and 1 Guest are viewing this topic.

scomp

    Topic Starter


    Rookie

    help needed in generating all combinations of 8 numbers
    « on: June 15, 2008, 07:43:24 AM »
    hi everyone,

                 I am looking for a algorithm which can generate all combinations of 8 numbers.

    can anyone know how to do this.

    please tell me.

    thank in advance.

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: help needed in generating all combinations of 8 numbers
    « Reply #1 on: June 15, 2008, 08:39:21 AM »
    Quote
    I am looking for a algorithm which can generate all combinations of 8 numbers

    Single digit numbers? Double digit numbers? Permutations? Combinations?

    Wasn't an answer posted here? With a few changes and changing alchemist to numbers, you should be able to find a solution.

     8)

    Note: I forgot to mention in the previous post that the C program can be compiled with the Tiny C Compiler
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    Spasm



      Greenhorn

      Re: help needed in generating all combinations of 8 numbers
      « Reply #2 on: June 18, 2008, 04:31:33 AM »
      Code: [Select]
      for (int i = 0; i < 100000000; i++)
      cout << i << endl;

      Is that what you're looking for?  Another way you could do it is to nest 8 loops inside of each other.

      Code: [Select]
      for (int i1 = 0; i1 < 10; i1++) {
      cout << i1;
      for (int i2 = 0; i2 < 10; i2++) {
      cout << i2;
      for (int i3 = 0; i3 < 10; i3++) {
      etc...
      }
      }
      }

      And when you get to i8, print out a new line.