-
with random numbers. Cyclic generation, the next generation checks whether the generated random number has been generated.
-
I will only practice.
Sorry for not saying.
-
Analysis:
1) Generate 50 numbers, the sum is equal to 200, meaning 200 50 = 4 Each number is averaged as 4
2) Each random number cannot be generated arbitrarily, otherwise the sum of 50 numbers cannot be guaranteed to be 200
3) Generate the first (or first) random numbers, in the range of 1 - 9, as the number of numbers generated, the range may become smaller (meaning the range = 1 - less than 9 values).
4) Calculate the maximum value of the current limit = (200 - the sum of the generated numbers) - the number of remaining numbers "-1) *1
If the result is greater than 9, it is 9
5) Calculate the minimum value of the current limit = (200 - the sum of the generated numbers) - the number of remaining numbers "-1) *9
If the result is less than 1, it is 1
6) The last number (i.e. the 50th) cannot be randomly generated, otherwise there is no guarantee that the result will be equal to 200
The following ** have been tested.
class program
else The last digit cannot be randomly generated, otherwise there is no guarantee that the total generated will be equal to 200.
Current Value: , Current Cumulative Value:"current, sum);;
-
int count =50;Quantity 50
int max = 200;and for 200
int array = new int[count];Stores the generated random number.
int sum = 0;Initializes the sum of the generated random numbers.
random random = new random();
for(int i = 0 ; i < i++ count--)
else the first 49 numbers.
After the end of the loop, the sum of 50 random numbers is satisfied to 200, all of which are stored in the array and called as needed.
If you write it by hand, there may be a misspelling of some words, so the landlord can try it.
No, the condition judgment is wrong, I think about it.
Forehead. It seems to be right.,The landlord saw that you can go to the actual environment to try it.,I'm off work.,The computer at home isn't even installed vs.,It's inconvenient to try.。 Even if the local values are not very accurate, there is certainly nothing wrong with the idea.
Uh, upstairs faster than me, tragedy.
-
Is it all combined? Or is it just a combination?
-
lz This is a console application You didn't say what type you wanted, give this first.
static void main(string args)if (count ==200)
and for" +count);
flag = 10;
-
Add using at the front, or directly in front of graphics.
There is a corresponding ** on the Internet, you can check it yourself!
Random numbers in pascal.
Random numbers refer to a series of numbers that theoretically have no rules to follow, have an equal probability of each number appearing within a specified range, and cannot be used to follow the previous number. The basic principle of a general random number generator is: first, initialize a random seed, the initial value of which can be an arbitrary integer; Every time a random number is obtained, a special operation is performed based on the random seed, a random number is obtained and returned, and then some operation is performed on the random seed to change the value of the random seed. >>>More
Because you're superimposing, it should be n+(n-1)+
So sum(n-1) should be called. >>>More
2. In the second step, if you want to get the brand of the phone or tool you are debugging, you can use brand. >>>More
Automate knowledge management. Office automation makes all kinds of documents electronic, and realizes the storage of documents in the form of electronic filing cabinets, and uses and shares them according to permissions. >>>More