i=20
j=10
if i<j then print j
print i
input “x=”;x
If x>8 then y=3*x-2 else y=2*x+1
print “y=”;y
end
(x的值输入为6)
运行结果为( )

wine_ value=int (input ("请输入酒精含量:") )
if wine. _value<20:
print ("不构成酒驾")
else:
if 80>wine_ value>=20:
print ("构成酒驾")
else:
print ("构成醉驾")
请利用列表实现程序的功能,在划线处将程序补充完整。
mc=(input (“请输入运动会项目名词(1~6):”)) #输入名次,转化为整型
1st=[7,5,4,3,2,1] #定义一个得分列表
if mc>=1 and mc<=6 : #名次在1-6名之间,索引位置
df= #根据索引取列表中相应的成绩
print(“项目得分为:”, )
else:
print(“输入的名次不在[1~6]范围!”)
i=4
a=5
If i > 3 Then a = a + 5
Else a = a + 2
End If
写出本程序段运行后,变量a的值。
c = 0
For i = 1 To 12
If 12 Mod i = 0 Then
c = c + 1
End If
Next i
Text1.Text = Str(c)
程序运行后,在文本框中输出为:。
下列程序的功能是:当x<50时,y=0.8×x;当50≤x≤100时,y=0.7×x;当x>100时,输入的数据超出范围。请填空。
Private Sub Command1_Click()
Dim x As Single
x=InputBox("请输入x的值!")
Case x < 50
y=0.8 * x
Case 50 To 100
Print "输入的数据超出范围!"
End Select
Print x, y
End Sub
在VB中有三种程序结构,其中的分支结构中有一种多分支结构,可以针对多种情况进行编程。在编写移动的坦克游戏中,其中有这一段代码
|
1 Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer) 2 Select Case KeyCode 3 Case 37 4 Image1.Picture = LoadPicure(App.Path& "\pic\tank1.jpg") 5 If Image1.Left - 20 < 0 Then 6 Image1.Left=0 7 Else 8 Image1.Left= Image1.Left-20 9 End If |
x =5
If x<=12 Then
y=3*x
Else
y=4*x
End If
Print y
a=int(input())
if :
print("7的倍数" )
else:
print("不是7的倍数")
是语句,该语句不循环,只有把它放入指令块内才会循环。若要增加一行“否则如果为……则”可以单击指令块左下角的完成。
指令块属于指令块,它可以独立于程序里的其他部分存在;当按钮A被按下时,是以为幅度更改改变亮度。
指令块是指令块,可以独立运行,也可以同时添加多个。
| a=10 b=5 if(a<<b): print("a比b小") |

Private Sub Command1_Click( )
a= Val(Text1. Text)
b= Val(Text2. Text)
IfThen
Max=
Else
Max=b
End If
Text3.Text=
End Sub
