Ps: Brother do not understand what 5^5-4, brother only use code to speak, a line of recursion directly return to fix, the whole network the most awesome code, not one.
Ps: Reprint Please specify the Source: Liaocheng University Sun Yupeng. Thank you.
5 Monkeys a peach, the 1th only first to, will be the average peach divided into 5, found one more, ate this one, and took their own, the 2nd monkey came to see only 4,
He did not know that had been divided, and also the peach on average 5, found that one more, he also ate this one, and took his own that, the 3rd monkey came to see the ground Also
Only 4, he also divided the peach average of 5, also found one more, he also like them, ate this one, also took away his own, the 4th monkey is also divided 5,
Eat a lot of one, took their own that part, the 5th monkey came, the same as the remaining 4 of the average divided into 5, but also a more, eat, ask how many peaches a total.
#include <stdio.h>
int devide (int result, int sum, int i, int monkey)
{result
= i = = 1? sum:result;< C3/>return result% Monkey = 1? (i = = = = = = = Monkey Sum:devide (result-1)/5 * 4, SUM, i+1, monkey)): Devide (Result, sum+1, 1, monkey);
}
int main ()
{
printf ("Number of Peaches is:%d\n", devide (0, 0, 1, 5));
return 0;
}