VB编程:随机产生10个100~200的整数,打印其中7的倍数的数并求出它们的总和!
1个回答
展开全部
Dim n(10) As Integer, i As Integer = 0, j As Integer = 0, temp As Integer
Dim min As Integer = 0, sum As Long = 0
For i = 1 To 10
n(i) = Int(Rnd() * 100) + 100
Next i
TextBox1.Text = TextBox1.Text & "随机数为:" & vbCrLf
For i = 1 To 10
TextBox1.Text = TextBox1.Text & n(i) & " "
Next
TextBox1.Text = TextBox1.Text & vbCrLf
TextBox1.Text = TextBox1.Text & "随机数中7的倍数为:" & vbCrLf
For i = 1 To 10
If n(i) Mod 7 = 0 Then
sum = sum + n(i)
TextBox1.Text = TextBox1.Text & n(i) & " "
End If
Next
TextBox1.Text = TextBox1.Text & vbCrLf
TextBox1.Text = TextBox1.Text & "7的倍数的数的和是" & sum.ToString & vbCrLf
追问
VB的考试题,过程就这样写下来吗?😱太谢谢了
好复杂啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |