Dim a(1 To 5) As Integer
Dim f As Boolean
a(1) = 23: a(2) = 12: a(3) = 56: a(4) = 34: a(5) = 10
i = 1: f = True
Do While i <= 5 And f = True
If a(i) = 56 Then f = False
i = i + 1
Loop
Label1.Caption = i
提示:本题“除 2 取余倒排法”的方法将十进制转化为二进制,算法如下: 例如十进制数“97”转化为二进制的过程如右图所示:
因此“97”二进制值为:1100001
Dim a As Integer, c As Integer, w As Integer, i As Integer
Dim s As String, k As String
c = 0
For m = 1 To 100
k = ""
i = 2 * m
Do While i > 0
a=i Mod 2
k = str(a) + k
Loop
For n = 1 To Len(k)
s = Mid(k, n, 1)
If s = "1" Then w = w + 1
Next n
If w = 4 Then
c = c + 1
End if
Next m
Text1.Text = Str(c) End Sub
Dim i As Integer, Sum As Integer
Dim a(1 To 6) As Integer, b(1 To 6) As Integer
Sum = 0
a(6) = 18: a(5) = 7: b(6) = 14: b(5) = 16
For i = 4 To 1 Step -1
a(i) = a(i+2)-a(i+1)
b(i) = b(i+2)-a(i)
If b(i) Mod 3 = 0 Then Sum = Sum + b(i)
Next i
Textl .Text = Str(Sum)
该程序段运行后,文本框text1中显示的内容是( )
Dim M(10) as integer
For i = 0 To 10
M(i) = 2*i
Next i
Print M(M(3))
c = 1: s = 10
Do While c <= s
For i = s To c + 1 Step -1
If Then
t = a(i - 1): a(i - 1) = a(i): a(i) = t
End If
Next i
For i=
If Then
t = a(i + 1): a(i + 1) = a(i): a(i) = t
End If
Next i
c = c + 1
s = s - 1
Loop
上述程序段三个方框处的语句分别为( )
Dim i As Integer,sum As Integer
Dim a(1 To 6)As Integer,b(1 To 6)As Integer
Sum=0
a(6)=18:a(5)=7:b(6)=14:b(5)=16
For i=4 To 1 Step-1
a(i)=a(i+2)-a(i+1)
b(i)= b(i+2)-a(i)
If b(i)Mod 3=0 Then sum=sum+b(i)
Next i
Text1.Text=Sir(sum)
该程序段运行后,文本框Text 1中显示的内容是( )
For i=1 To 9
For j=10 To i+2 Step-1
If a(j)<a(j-2) Then
t=a(j): a(j)=a(j-2): a(j-2)=t
End If
Next j
Next i
数组元素a(1)到a(10)的值依次为“3,17,2,14,15,6,7,18,9,4”,执行该程序段后,数组元素a(8)中的值为( )
请用Python语言回答下列问题:
Private sub command1_click()
Dim a(1 to 20) as integer,b(1 to 20) as integer,i as integer
Dim j as integer,t as integer,p as integer,k as integer,xiaofen as integer
‘从文本框读取AB两队各场的比分分别存数组a、b,场次k,代码略
For i=1 to k-1
For j= 1 to ①
If ② then
t=a(j):a(j)=a(j+1):a(j+1)=t
t=b(j):b(j)=b(j+1):b(j+1)=t
End if
Next j
Next i
p=0 : xiaofen=0
For i=1 to k
If a(i)>b(i) then ③
xiaofen = xiaofen+a(i)-b(i)
List1.Additem str(a(i)) + “:”+ str(b(i))
Next i
If p*2>k or k=p*2 and xiaofen>0 then
Text2.text = “A队获胜”
Elseif then
Text2.text = “B队获胜”
Else
Text2.text = “两队平局”
End if
End sub
① ② ③
import math
h = 500
g = 9.8
t = math.sqrt(2*h/g)
hx = g*(t-1)*(-1)/2
hh = h-hx
print(“小球最后1秒下落的位移是:”,hh,“m”)
s="Happy National Day!"
m=____
if m=="Happy":
print("Happy to you!")
elif m=="National":
print("Best Wishes to you!")
else:
print("It's a fine Day!")