To find the maximum, sum, and return of variables these three types of programming topics that are very important for mastering core ideas are the three kinds of topics that represent three kinds of ideas, all of which are very important ideas, It is important to master the core of these three types of programming questions rather than just remembering the three types of programming topics.
Maximum value: If the maximum value is three digits, we can also use the if else this function, if there are a lot of numbers, we need to set a new variable for the maximum value is out, set the sum out, the idea of the maximum value becomes our sum is equivalent to a basket, And then a row of numbers in front of us, we brought in a number of baskets, and then brought in a number of baskets, if the number of later than the basket in the number of large we will leave behind the number, the basket in the number of lost, if the number of baskets than the later number of large, leaving the basket in the number. So it's a circular action to keep a number from a row of numbers and put it in the basket. Take out this number is a, and set for the loop, the maximum set for Max,max<a is Max=a, that is, as long as the number of the basket in the big left, not to move, how many times the number of cycles, Finally, no matter how many numbers can find the maximum value.
Summation: It is also a typical application of a new idea. and set to sum, then sum is also a basket, put the number of the added to a basket, and finally you can get these numbers and values. To set the number to add to the a,a and then set to the loop (that is, the action to put into the basket again and again), Sum=sum+a,sum constantly as a new value to continue to receive a, and finally no matter how many numbers we can get their final and value. Summation is also the idea of using numbers to load baskets.
Exchange variable: The Exchange variable in the maximum value can be used, such as the comparison of three numbers to find the maximum value, first compare the first two number who big, big put the front, small put behind, and then compare the two size, big put in front, small put behind, so, three number is according to the order from big to small in the arrangement. The idea of exchanging variables is to put the idea of an empty bottle, you must first int temp, that is, first in the number to exchange into an empty bottle, and then Exchange. Swap a pair of numbers with an empty bottle, then swap a pair of numbers again with an empty bottle, exchange several times to use a few empty bottles.