The question that the master may not be able to solve, who dares to come!! Use C to arrange the numb

Updated on society 2024-05-23
13 answers
  1. Anonymous users2024-02-11

    Use the algorithm of the standard library, concise and efficient:

    #include

    #include

    #include

    using namespace std;

    void main()

    vectora;

    for (int i=0;i<4;++i){;

    do{for (unsigned int i=0;i#include

    #include

    void permutation(vector& a, unsigned int m, unsigned int n)

    if (ma;

    for (int i=0;i<4;++i){;

    permutation(a, 0,

  2. Anonymous users2024-02-10

    Hehe, I see you're engaged in curriculum design, huh.

  3. Anonymous users2024-02-09

    I'm sorry, I really don't understand!

  4. Anonymous users2024-02-08

    I'm taking the test, this question is too simple, right?

    If you've learned how to permutate, you'll be able to solve this problem.

    Write it this way. s=1

    if n=1 then

    s=1else

    for i=1 to n

    s=s*inext i

    I think this is the way to write endif, but there are other ways to write it.

  5. Anonymous users2024-02-07

    I have **, I can input a total of several numbers, and output a permutation of several numbers.

    For example, 4 3 then take 3 out of 4 and arrange them.

    #include

    using namespace std;

    bool increase(int* a,int num,int max);

    bool isequal(int* a,int num);

    void print(int*a,int num);

    int main()

    int max;

    int num;

    int* a;

    cout<<"Enter the maximum number"<>max;

    cout<<"Enter the number you want to arrange"<>num;

    if(num>=max)

    cout<<"Typing error"a=new int[num];

    for(int i=0;iwhile(true)

    if(!isequal(a,num))

    print(a,num);

    increase(a,num,max);

    if(a[0]==max)

    break;

    delete a;

    return 0;

    bool increase(int* a,int num,int max)

    int index=num-1;

    while(true)

    a[index]++

    if(a[index]==max)

    if(index==0)

    return false;

    a[index]=0;

    index--;

    elsereturn true;

    bool isequal(int* a,int num)for(int i=0;ireturn true;

    return false;

    void print(int*a,int num)for(int i=0;icout<

  6. Anonymous users2024-02-06

    It's done with a recursive function.

  7. Anonymous users2024-02-05

    The score is not high enough, leave it to the masters.

  8. Anonymous users2024-02-04

    A total of 10 starvation chains below c = 120 species above.

    There are 8 kinds of three numbers next to each other.

    Two numbers are adjacent to each other, and there are only one side of the two numbers, and there are 2 7 = 14 kinds of two counts.

    There are 7 6 = 42 kinds of two numbers that are adjacent to each other, and there are two numbers left and right.

    There are 120-8-14-42 = 56 species that are not adjacent.

  9. Anonymous users2024-02-03

    In order to welcome the 2010 Guangzhou Asian Games, a building installed 5 lanterns, the order of their shining is not fixed, each lantern can only be red, orange, yellow, green, blue in one color, and the color of the 5 lanterns is different.

    Remember that these 5 lights are flashing in an orderly manner, and in each flash, there is only one light flashing per second, and the time interval between the two adjacent flashes is 5 wonders. If you want to achieve all the different flashes, then the time it will take is at least.

    a, 1205 seconds seconds.

  10. Anonymous users2024-02-02

    How many different ways are there to dye the 6 faces of a cube with 5 colors, (the colors are allowed to run out), and the two adjacent faces (with common edges) to dye different colors? 、

  11. Anonymous users2024-02-01

    There are 10 types of eggplant.

    There are 2 kinds of bending halls for each buried hidden selection method.

    There are 20 types in total.

  12. Anonymous users2024-01-31

    1 2

    Suppose, the flower bed is the shape above. That is, 1 and 4 are not adjacent, and 2 and 3 are not adjacent.

    Let's start with 1.

    I'm in Zone 1, and I can put any suit, which is 4 cases, and the face is divided into two situations:

    The first way: Zone 4 is the same as Zone 1, then 2 and 3 have 3 options, and the expression is 4*1*3*3

    Second: Zone 4 is different from Zone 1, then Zone 4 has 3 options, while Zone 2 and Zone 3 each have only 2 options, and the expression is 4*3*2*2

    Therefore, if we consider that 1, 2, 3, and 4 areas are all the same, there are 4*1*3*3+4*3*2*2=36+48=84 types.

  13. Anonymous users2024-01-30

    Think of it this way, the first can be selected among the four flowers, after the first one is selected, the second one can be selected among the flowers except the first one, the third one can be selected among the flowers except the second one, and the fourth one can be selected among the flowers except one and three.

    One and three flowers are the same: 4*3*3=36

    One and three flowers are different: 4*3*2*2=12*4=48

Related questions
23 answers2024-05-23

The woman who loves you deeply, do you love her? If you like each other, then together, what are you grinding? >>>More

1 answers2024-05-23

In the blink of an eye, I have reached the second year of junior high school, and I will be a graduate in another year. I will also step into the battlefield of the high school entrance examination, can I plan well in these two years and work hard to get into the experiment or the first middle school? >>>More

20 answers2024-05-23

Summary. Hello dear, glad to answer for you. The female part of the song "Separation Does Not Necessarily Break Up" is sung by singer Xu Shan. >>>More

39 answers2024-05-23

After the meeting, you think about it again, and you will know the answer.

15 answers2024-05-23

When the first condition of this assumption is changed, the problem is easy. >>>More