题目
四则运算测试:每次运行,只能做十道题,题目通过产生随机数组成的两位数的四则运算式组成,
若是除法,四舍五入,保留小数点后两位
若是除法,四舍五入,保留小数点后两位
提问时间:2021-02-28
答案
Private Sub Command1_Click()
Dim i As Integer,k As Integer,s As Long,s1 As Double
Dim a As Integer,b As Integer,ab As String
i = 0
Randomize
a = Int(Rnd() * 99) + 30
Randomize
b = Int(Rnd() * 99) + 30
Randomize
k = Int(Rnd() * 10) + 1
s = 0
s1 = 0
If i > 10 Then
MsgBox "Sorry,每次只能运算10题!"
Exit Sub
End If
If k < 3 Then
ab = "+"
s = a + b
Else
If k < 6 Then
ab = "-"
s = a - b
Else
If k < 9 Then
ab = "*"
s = a * b
Else
ab = "/"
s1 = a / b
s1 = Format(s1,"0.00")
End If
End If
End If
If ab = "/" Then
Label1.Caption = a & " " & ab & " " & b & " = " & s1
i = i + 1
Else
Label1.Caption = a & " " & ab & " " & b & " = " & s
i = i + 1
End If
End Sub
Dim i As Integer,k As Integer,s As Long,s1 As Double
Dim a As Integer,b As Integer,ab As String
i = 0
Randomize
a = Int(Rnd() * 99) + 30
Randomize
b = Int(Rnd() * 99) + 30
Randomize
k = Int(Rnd() * 10) + 1
s = 0
s1 = 0
If i > 10 Then
MsgBox "Sorry,每次只能运算10题!"
Exit Sub
End If
If k < 3 Then
ab = "+"
s = a + b
Else
If k < 6 Then
ab = "-"
s = a - b
Else
If k < 9 Then
ab = "*"
s = a * b
Else
ab = "/"
s1 = a / b
s1 = Format(s1,"0.00")
End If
End If
End If
If ab = "/" Then
Label1.Caption = a & " " & ab & " " & b & " = " & s1
i = i + 1
Else
Label1.Caption = a & " " & ab & " " & b & " = " & s
i = i + 1
End If
End Sub
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1为什么称莫高窟为祖国西北的一颗明珠简单的一句话
- 2There is no denying the fact that+同位语从句 能否把that前的用语法解释一下?总感觉不合语法
- 3我喜欢那本妈妈给我的书 我讨厌那个玩电脑的男孩 我们不想当抄作业的学生 这三句用英语怎么说
- 4物体只有吸热才能使温度升高吗?
- 5我想做一个电箱,请问500W/220V的水泵应选多大的漏电开关、多大的交流接触器?计算公式是怎样?
- 6城南旧事主要内容100字左右
- 7写春天的景色
- 8如何检验生石灰中是否有碳酸钙 两种方法 请简要叙述.检验步骤、现象及结论
- 9be missed 和missing有什么区别?
- 10一个电流表的量程为i1等于ima内阻r1等于0.40欧若要吧量程扩大到10ma需要怎样
热门考点