CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012
    Posts
    5

    Help in making a Permutation function

    Hello,

    I need help in writing a function which declared as following:

    void ReconstructPermutation(pointer* start, int perm[], int* permSize);

    start: contain the address of the cell (which mean that it is a pointer to a pointer, this is why its type is pointer*).

    the function update the array perm to contain the Permutation as numbers in the right order, and update the permutation length by permSize.

    We can assume that perm is large enough to contain the permutation.

    permutation example:


    running example:

    int perm[4], permSize, i;

    pointer seq[4] = {NULL}; /* seq is of type array of pointers. */
    /* Define the permutation with pointers: */

    pointer* start = seq + 2; /* start is of type pointer to pointer. */

    seq[2] = seq + 0; seq[0] = seq + 3; seq[3] = seq + 1;

    ReconstructPermutation(start, perm, &permSize);

    printf(">>> PERMUTATION IS: \n");

    for (i = 0 ; i < permSize ; ++i)
    printf("%d ", perm[i]);
    printf("\n");

    Output:
    >>> PERMUTATION IS: 2 0 3 1

    Thank you,
    Dan

  2. #2
    Join Date
    May 2012
    Location
    Bonn, Germany
    Posts
    43

    Re: Help in making a Permutation function

    Looks like you're trying to get other people to solve your homework.
    The purpose of homework is that you learn something. We can't do that for you.
    If you have a concrete problem, tell what it is. But it looks like you didn't even try anything.

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