题库 高中信息

题干

下列程序的功能是:当用户点击窗体下方的“石头”(command1)、“剪子”(command2)、“布”(command3)任意一个按钮的时候,电脑也会在Label1上随机显示出一个石头、剪刀、布(显示在label1上),程序判断出胜负(平局算负)将结果显示到label3上。

Private Sub Command1_Click()
Label1.Caption = sj ‘计算机随机产生一个值
Label2.Caption = Command1.Caption
If cp(Label1.Caption, Label2.Caption) Then ‘判断胜负
     = "乙方负"
Else
Label3.Caption = "乙方胜"
End If
End Sub
Function sj() As String '随机生成石头、剪刀、布
i =   ‘随机生成1~3任一整数
If i = 1 Then sj = "石头"
If i = 2 Then sj = "剪刀"
If i = 3 Then sj = "布"
End Function
____________②_________________
上一题 下一题 0.99难度 填空题 更新时间:2019-05-29 05:27:26

答案(点此获取答案解析)