First of all, let me talk about the general idea. An algorithm is used to select random numbers. There should be this function in the C language library, which can make the selected numbers fluctuate within a range, but you should always pay attention to the fact that the sum of random numbers is less than n (the total amount of money), and the last one is just equal to n. First, enter the total number n and the total number of people A, and then enter the number of people A to generate a number of random numbers, so as to ensure that their sum is equal to n (here, a temporary variable is defined to count the number). You don't need a pointer in the program, you can define an array. If it is similar to a WeChat red envelope and has a decimal, you can set a floating type.
Give you a link, which is a web page link of how C language generates random numbers.