For i=3 to 15 step x
Print “∗”
Next i
下列说法中正确的是( )
①6542-2456=4086 ②8640-0468=8172 ③8721-1278=7443 ④7443-3447=3996
⑤9963-3699=6264 ⑥6642-2466=4176 ⑦7641-1467=6174
编写程序实现实现上述功能。从文本框Text1中输入一个任意的数字不完全相同的四位正整数,在文本框Text2中输出掉进黑洞的步数。实现上述功能的VB代码如下,但加框处代码有错,请改正:
Private Sub Command1_Click()
Dim a(1 To 4) As Integer, c As Integer, t As Integer
Dim x As Integer, y As Integer, i As Integer, j As Integer
x = Val(Text1.Text)
c = 0
Do While x <> 6174
For i = 1 To 4 '把四位正整数x的每一位数字取出并存放到数组a中
a(i) = x Mod 10
' (1)
Next i
For i = 1 To 3
For j = i + 1 To 4
If Then ' (2)
t = a(i): a(i) = a(j): a(j) = t
End If
Next j
Next i
x = a(1) * 1000 + a(2) * 100 + a(3) * 10 + a(4)
y = a(1) + a(2) * 10 + a(3) * 100 + a(4) * 1000
x = x - y
c = c + 1
Loop
Text2.Text = Str(c)
End Sub
⑴ ⑵
For i=1 To 2
For j=1 To 5-i
If a(j+1)<a(j) Then t=a(j):a(j)=a(j+1):a(j+1)=t
Next j
Next i
数组a(1)到a(5)中数据分别为56,23,78,11,8,执行上述VB程序段后,数组元素的值分别为( )
Private Sub Command1_Click()
Dim a(1 To 100)As String, s As String, ch As String, word
As String
Dim i As Integer,j As Integer,k As Integer, numb As Integer
s=Text1.Text:k=0:word=" "
For i=1 To Len(s)
ch=Mid(s,i,1)
If ch>="a"And ch<="z"Оr ch>="A"And ch<="Z"Then
If ch>="A" And ch<="Z"Then ①
word=word+ch
Else
flag=False
For j=1 To k
If a(j)=word Then flag=True
Next j
If Not flag And word<> ''Then
②
a(k)=word
numb=numb+1
End If
③
End If
Next i
Text2.Text=Str(numb)
End Sub
①②③
Private Sub Command1_Click()
Dim a(1 To 100) As Integer, y(1 To 100) As String
Dim i, j, k, n, c, res As Integer
n = Val(Text1.Text) '数组 y 记录路径上的数字,n 为行数
For i = 1 To n * (n + 1) / 2
a(i) = Int(Rnd *10)
Next i
List1.AddItem Str(a(1))
y(1) = Str(a(1)): s = "": k = 1
For i = 2 To n
For j = 1 To i
x = k + j - 1
s = s + Str(a(x)) + " "
If j = 1 Then
y(x) = y(x - i + 1) + Str(a(x))
a(x) = a(x) + a(x - i + 1)
ElseIf j = i Then
y(x) = y(x - i) + Str(a(x))
a(x) = a(x) + a(x - i)
ElseIf Then
y(x) = y(x - i + 1) + Str(a(x))
a(x) = a(x) + a(x - i + 1)
Else
y(x) = y(x - i) + Str(a(x))
a(x) = a(x) + a(x - i)
End If
Next j
List1.AddItem s
s = ""
Next i
For c = k To k + n - 1
If a(c) > Max Then Max = a(c): res = c
Next c
List1.AddItem "最大和是:" + Str(Max)
List1.AddItem "访问到的数据依次是:" +
End Sub
Dim a(0 To 9)As Integer, t As Integer, x As Integer t = Val(Text, Text)
Do While t<>0
a(t Mod 10) = 1
t = t\10
LooP
For i = 0 To 9
x = x + a(i)
Next i
在Text1中输入20181230,执行该程序段后,x的值为( )
dic={"Name":"admin","Password":"j1l234y"}
user-input("请输入用户名:")
psd-input("请输入密码:")
if
print("用户名或密码错误!")
else:
print(" 登录成功!")