CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #1
    Join Date
    Sep 2006
    Location
    Wantagh,NY
    Posts
    151

    How to do this??

    I saw this code on another site and it does exactly what I want it to, problem is that in order to have acccess to the header file, you must register and pay. Is there another way to do this easily?

    Code:
    #include <codecogs/maths/combinatorics/permutations/partition.h>
    #include <iostream>
    int main()
    {
      int tau[9] = {2, 3, 9, 6, 7, 8, 5, 4, 1};
      std::vector<int> result = Maths::Combinatorics::Permutations::partition(9, tau);
      std::cout << "The partition of the [9] set induced by the Tau permutation is:";
      std::cout << std::endl;
      for (int i = 1; i <= 9; i++)
      {
        for (int j = 0; j < 9; j++)
          if (result[j] == i)
          {
            std::cout << "Subset " << i << " : { ";
            for (; j < 9; j++)
              if (result[j] == i)
                std::cout << tau[j] << " ";
            std::cout << "}" << std::endl;
          }
      }
      return 0;
    }
    Output:
    The partition of the [9] set induced by the Tau permutation is:
    Subset 1 : { 2 3 9 1 }
    Subset 2 : { 6 8 4 }
    Subset 3 : { 7 5 }

    Note: This is not my compiled output, this is the output posted on the site.
    Last edited by gammaman; February 13th, 2009 at 07:25 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured