热心网友
回答时间:2025-01-18 09:45
我要改一下
绝对可以
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer
a = Int((10 * Rnd) + 1)
b = Int((10 * Rnd) + 1)
MsgBox a, , "第一个数为"
MsgBox b, , "第二个数为"
c = InputBox("请输入你的答案")
If c = a + b Then
MsgBox "恭喜你答对了!"
End If
If c <> a + b Then
MsgBox "很遗憾,你回答错了!"
End If
End Sub
收起
热心网友
回答时间:2025-01-18 09:45
Module module3
Sub Main()
Dim num1, num2, sum As Integer
Dim answer As Integer '用户输入的答案
Dim rand As New Random()
num1 = rand.Next() Mod 10 '得到随机数,控制在[0,10]之间
num2 = rand.Next() Mod 10
sum = num1 + num2
Console.WriteLine("请输入您的答案:")
answer = Integer.Parse(Console.ReadLine()) '得到用户输入的答案
If (answer = sum) Then
Console.WriteLine("恭喜您,猜对了!")
Console.WriteLine("我们就是 " & num1 & " 和 " & num2)
Else
Console.WriteLine("很遗憾,猜错了,继续努力... ...")
Console.WriteLine("其实我们是 " & num1 & " 和 " & num2)
End If
End Sub
End Module
收起