Home > Back-end >  Bosses, solving 1-9 is divided into a set of three three digits, and the Numbers in each group shall
Bosses, solving 1-9 is divided into a set of three three digits, and the Numbers in each group shall

Time:09-23

Said the train of thought, to write code on my own,

CodePudding user response:

Such as calculating do not calculate a group of 123 and 321 in the same situation?
If not, May 1-9 nine Numbers for all arrangement, and then before the triplet, middle triplet, triplet, after can
If, on the basis of the above to remove duplicate data

CodePudding user response:

reference 1st floor qybao response:
such as calculating do not calculate a group of 123 and 321 in the same situation?
If not, May 1-9 nine Numbers for all arrangement, and then before the triplet, middle triplet, triplet, after can
If, on the basis of the above to remove duplicate data

Calculate, the whole arrangement can explain

CodePudding user response:

refer to the second floor m0_46218308 response:
, the whole arrangement can explain it

The permutation and combination of learned maths? Have not learned to search for information on the Internet to learn to understand first
9 number of permutations as follows, each position is put in different Numbers is a kind of arrangement
123456789
123456798
123456879
.
132456789
132456798
132456879
.
.
912345678
912345687
912345768
.
.
987654321

Find out nine after all arrangement of array, three three segments can

CodePudding user response:

This is actually a full array of applications, (note, arrange it all, in the circle circle of small data enumeration method, still have a certain visibility,)
Its role is to output a set of data (such as 123456789) all arrangement of may, I like writing, brother understand:
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//the whole arrangement program
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

# define N 3

#include

Int d [N].

//output it
Void the write ()
{
int i;
for(i=0; iPrintf (" % d ", d [I]);
printf("\n");
}

Exchange//d and d [j] [I]
Void swap (int, int j)
{
Int t;
[I] t=d.
D=d [I] [j];
D [j]=t;
}

//the function of it is "get d [k] ~ [N - 1) d all arrangement" within the scope of the
Int f (int k)
{
int i;
If (k==N - 1)//just one more number, do not have what good arrangement, the output can be
Write ();
The else
For (I=k; i{
Swap (k, I);//to the first
F (k + 1);//the rest of the recursive run
Swap (k, I);//change back
}
}

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//the main function
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Int main (int arg c, char * argv [])
{
int i;
for(i=0; i[I] d=I + 1;
F (0);
return 0;
}

CodePudding user response:

Look not to understand sigh agghh agghh ahhh

CodePudding user response:

STL is not a full arrangement function?

CodePudding user response:

reference 4 floor swift response:
this is actually a full array of applications, (note, arrange it all, in the circle circle of small data enumeration method, still have a certain visibility,)
Its role is to output a set of data (such as 123456789) all arrangement of may, I like writing, brother understand:
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//the whole arrangement program
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

# define N 3

#include

Int d [N].

//output it
Void the write ()
{
int i;
for(i=0; iPrintf (" % d ", d [I]);
printf("\n");
}

Exchange//d and d [j] [I]
Void swap (int, int j)
{
Int t;
[I] t=d.
D=d [I] [j];
D [j]=t;
}

//the function of it is "get d [k] ~ [N - 1) d all arrangement" within the scope of the
Int f (int k)
{
int i;
If (k==N - 1)//just one more number, do not have what good arrangement, the output can be
Write ();
The else
For (I=k; i{
Swap (k, I);//to the first
F (k + 1);//the rest of the recursive run
Swap (k, I);//change back
}
}

//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//the main function
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Int main (int arg c, char * argv [])
{
int i;
for(i=0; i[I] d=I + 1;
F (0);
return 0;
}

The recursive understanding what you need, this two days have been looking at the
Two functions like this sandwiching a recursive function didn't figure out how to run, Hanoi that too, but simple as fib sequence is understand

CodePudding user response:

Stay away from high number for many years

CodePudding user response:

#include
#include
#include

Void swap (char * a, char * b)
{
Char temp.
Temp=* a;
*=* b;
* b=temp;
}

Void Allarrange (char * STR, int k, int len)
{
int i;
If (k==len)
{
Static int s_i=1;
//printf (" % d array is: \ n \ t % s ", s_i + +, STR);//the whole array output
Printf (" % d array is: \ t ", s_i + +);//changes on this subject output
Printf (" % % % c c c, "STR [0], STR [1], the STR [2]).
Printf (" % % % c c c, "STR [3], the STR [4], the STR [5]);
Printf (" % % % c c c \ n ", STR [6], STR [7], STR [8]).
}
The else
{
For (I=k; i<=len; I++)
{
Swap (STR + I, STR + k);
Allarrange (STR, k + 1, len);
Swap (STR + I, STR + k);
}
}
}
Int main ()
{
Char STR [10]={' 1 ', '2', '3', '4', '5', '6', '7', '8', '9'};
Allarrange (STR, 0, strlen (STR) - 1);
return 0;
}
Below is running as a result, there are 9! Time, that is, 362, 880 group, each group there are three 3 digits,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related