Problem: How does 胊 Sp realize take out 3 highest cent and 3 lowest cent?
Solve train of thought:
1, sort of will whole array, 3 maximum that delete two end and 3 the least values (another netizen puts forward! )
2, choose piece among them 3 the largest number and 3 the smallest number, delete its! (my train of thought! )
I feel my method should be a few more feasible, because want the number that delete to have 3 only the biggest, 3 the smallest, not was necessary to have all number sort, become especially data is very much when, will waste a lot of resource! The order that I write is as follows:
| It is quotative content below:
<%@LANGUAGE= "VBSCRIPT" CODEPAGE= "936" %> Call DeleteMax(UBound(Arr) , 3)’ deletes 3 the largest number! Every number says Call GetBack()’ with - 1, the will smallest number becomes the largest number! Call DeleteMax(UBound(Arr) , 3)’ is deleted say with - 1 later 3 the largest number! Call GetBack()’ is reductive each numberFor Kk= 0 To UBound(Arr)’ exports each number |
Have 3 subprograms among them:
1, DeleteMax(Arr_total, willdelete)
Function: Delete a certain number of several the biggest, arr_total: The biggest usable suffix of array, willdelete: A number of the largest number that will delete.
2, Swap(num_a, num_b)
Function: Exchange two number
3, GetBack()
Function: Take every element of array with - 1, the will smallest number becomes the largest number!
Result:
The trial went how to delete an array element!
Clever application Redim and Preserve statement, be like:
| It is quotative content below:
Dim A()Redim A(10) |
The code of above, can finish, do not believe you to try. . .
