How to solve the problem of Page borrowing Books in C language algorithm
Editor to share with you how to solve the problem of borrowing books by Page in the C language algorithm. I hope you will get something after reading this article. Let's discuss it together.
1. Problem description
Page has five new books to lend to children A, B and C. if each person can only borrow one book at a time, how many different ways can he borrow it?
two。 Topic analysis
This problem belongs to the common permutation and combination problem in mathematics, that is, to find the total number of permutations and combinations of 3 different numbers from five numbers. We can number five books from one to five, and A, B and C can choose one of the five books each time, that is, each person has five choices, because it is impossible for one book to be lent to more than one person at the same time. Therefore, as long as the serial numbers of the books selected by these three individuals are different, it is an effective way to borrow them.
3. Algorithm design
For each person's selected book number, we can use exhaustive cycle, that is, from the range of each person's optional book number (1, 2, 3, 4, 5), so as to get feasible results. For the first person's choice, we can list it in a loop:: for (a = 1; a)