Dim i As Integer
Randomize
For i = 1 To n
a(i) =
Text 1. Text = Text 1. Text + Str(a(i))
Next i
Dim i As Integer, j As Integer, t As Integer
Dim left As Integer, right As Integer
Dim ans As Integer, flag As Bool ean
flag = True
’对数组a进行升序排序,代码略
i = n
Do While i > = 1 And flag
j = i - 1
Do While j > = 1 And flag.
left = 1
right = j - 1
Do While
If ans > a(left) + a(right) Then
left = left + 1
ElseIf ans < a(left) + a(right) Then
right = right - 1
Else
Text2. Text = Str(a(i))
flag = False
End If
Loop
j = j - 1
Loop
Loop
If flag Then
Text2. Text = "no solution"
End If
①
Const n=40
Const k=5
Dim f(1 To 500)As String
Dim sum As Integer
Private Sub Form_Load()
’读取sum张纸的信息,存入到数组f并显示在列表框List1中,代码略
End Sub
Private Sub Command1_Click()
Dim i As Integer,j As Integer,t As Integer,tmp As Integer
Dim a(500)As Integer,b(500)As Integer
Dim c(500)As Integer,d(500)As Integer
’读取每张纸信息,将页码存入到a数组中,活页本编号存入到b数组中
For i=1 To sum
a(i)=Val(Mid(f(i),4))
b(i)=
Next i
For i=1Tosum-1’对每一页先按照活页本编号、再按照页码从小到大排序
t=i
For j=i+1 To sum
If Then t=j
Next j
tmp=a(i):a(i)=a(t):a(t)=tmp
tmp=b(i):b(i)=b(t):b(t)=tmp
Next i
c(1)=a(1)’对于每个奇数位i,c(i)与c(i+1)分别存储连续页码的起始编号和结尾编号
d(1)=b(1)
s=1
t=a(1)
For i=2 To sum
If b(i)=b(i-1)And t+1=a(i)Then
Else
c(s*2)=t
s=s+1
d(s)=b(i)
t=a(i)
End If
Next i
c(s*2)=t
List2.AddItem "第1本书:"
List2.AddItem Str(c(1))+"-"+Str(c(2))
For i=2Tos
If d(i)<>d(i-1)ThenList2.AddItem"第"+Str(d(i))+"本书:"
List2.AddItem Str(c(2*i-1))+"-"+Str(c(2*i))
Next i
End Sub
'本过程从数据库中读入n件物品的编号和重量分别存数组num,w中,并在List1中显示,代码略。
Loop
If flag=True Then
Else
End If
图 a
data=line.split() #以空格分隔转换成列表
line=f.readline()
print(list[:5])
line_list=list[i] #遍历每一个列表元素
if line_list[3]=="是":
else:
Vac_F[line_list[1]]+=1
zu_per=Vac_T[i]/(Vac_T[i]+Vac_F[i]) #各组接种比例
if zu_per>zu_max:
zu_max=zu_per
zu=i