我不明白下面的代码,请帮忙.
它继续针对变量b返回类型不匹配错误.
Dim a As Integer
Dim b As String
a = InputBox("Input the number of items", "Total Number of Items.")
b = InputBox("Which Block?", "Total Number of Items.")
Do While b <> "a" Or "A" Or "B" Or "b"
MsgBox ("Invalid Block. Try again, Input A or B")
b = InputBox("Which Block?", "SELECT BLOCK.")
Loop
If b = "a" Or "A" Then
Me.ComboBox1.List = Worksheets("Sheet1").Range("a3:a39").Value
Else
Me.ComboBox2.List = Worksheets("Sheet2").Range("a3:a35").Value
End If
Run Code Online (Sandbox Code Playgroud) 我的目标是使用python创建一个空心钻石.
样本输入:
Input an odd Integer:
9
Run Code Online (Sandbox Code Playgroud)
样本输出:
*
* *
* *
* *
* *
* *
* *
* *
*
Run Code Online (Sandbox Code Playgroud)
但到目前为止,我有以下代码无法正常工作.请帮我修改代码以实现上述目标:
a=int(input("Input an odd integer: "))
k=1
c=1
r=a
while k<=r:
while c<=r:
print "*"
c+=1
r-=1
c=1
while c<=2*k-1:
print "*"
c+=1
print "\n"
k+=1
r=1
k=1
c=1
while k<=a-1:
while c<=r:
print " "
c+=1
r+=1
c=1
while c<= 2*(a-k)-1:
print ("*")
c+=1
print "\n"
k+=1
Run Code Online (Sandbox Code Playgroud)
上面的代码返回的结果离我的目标很远.
Input an odd integer: 7
*
* …Run Code Online (Sandbox Code Playgroud)