# How to use ASP to remove three highest points and three lowest points

Source: Internet
Author: User
Tags array
Today also helped a netizen, my slogan is "to help others for happiness!"

Question: How to achieve the use of ASP to remove three highest points and three minimum points?
Solution Idea:
1, sorting the entire array, delete both ends of the three maximum and three minimum values (another user proposed!) ）
2, pick out three of the largest number and three minimum number, delete it! (My train of thought!) ）

I think my method should be feasible, because the number of deleted is only three maximum, three minimum, there is no need to all the numbers are sorted, especially when the data are many, will waste a lot of resources! I wrote the following preface:
<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%
Dim Arr
Arr=array (91,39,46,24,14,56,31,32,56,89)

Call Deletemax (UBound (ARR), 3) ' Removes the three maximum number!
Call Getback () ' Each number is called-1, the smallest number into the maximum number!
Call Deletemax (UBound (ARR), 3) ' Deletes the three maximum number after 1!
Call Getback () ' Restore each number
For kk= 0 to UBound (ARR) ' Output per number
Response.Write (ARR (KK))
Response.Write ("<br>")
Next
Sub Deletemax (Arr_total,willdelete)
For m= 1 to Willdelete
For i= 0 to Arr_total-m
If ARR (i) >arr (i+1) Then
Call Swap (ARR (i), ARR (i+1))
End If
Next
ReDim Preserve ARR (arr_total-m)
Next
End Sub
Sub Swap (Num_a,num_b) ' Swap two numbers
X=num_a
Num_a=num_b
Num_b=x
End Sub
Sub Getback ()
For L=0 to UBound (ARR)
ARR (L) =arr (L) *-1
Next
End Sub
%> There are three subroutines:
1, Deletemax (arr_total,willdelete)
Function: Deletes a number of maximum numbers, Arr_total: The maximum available subscript for the array, Willdelete: The number of maximum numbers that will be deleted.

2. Swap (Num_a,num_b)
Function: Swap two numbers

3, Getback ()
function: Multiply each element of the array by 1, and the smallest number to the maximum number!

Help people experience:
Experiment with how to delete an array element!
Cleverly apply ReDim and preserve statements, such as:
Dim A ()
ReDim A (10)
' Want to delete the sixth element a (5)
For n= 5 to UBound (A)-1
A (n) =a (n+1)
Next
ReDim Preserve A (UBound (a)-1) above the code, can be completed, do not believe you try ...

Related Keywords:
Related Article

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.