VB编程题:统计7*7数组四周元素之和及四周元素中能够被7整除的元素的个数,并在标签中显示.Sum = 0For i = 1 To 7Sum = Sum + a(1,i)Next iFor i = 1 To 7Sum = Sum + a(7,i)Next iFor i = 2 To 6Sum = Sum + a(i,1)Next iFor i =
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 12:03:09
VB编程题:统计7*7数组四周元素之和及四周元素中能够被7整除的元素的个数,并在标签中显示.Sum = 0For i = 1 To 7Sum = Sum + a(1,i)Next iFor i = 1 To 7Sum = Sum + a(7,i)Next iFor i = 2 To 6Sum = Sum + a(i,1)Next iFor i =
VB编程题:统计7*7数组四周元素之和及四周元素中能够被7整除的元素的个数,并在标签中显示.
Sum = 0
For i = 1 To 7
Sum = Sum + a(1,i)
Next i
For i = 1 To 7
Sum = Sum + a(7,i)
Next i
For i = 2 To 6
Sum = Sum + a(i,1)
Next i
For i = 2 To 6
Sum = Sum + a(i,7)
Next i
lblSecond.Caption = Sum
n = 0
For i = 1 To 7
If a(1,i) Mod 7 = 0 Then
n = n + 1
ElseIf a(7,i) Mod 7 = 0 Then
n = n + 1
End If
Next i
For i = 2 To 6
If a(i,1) Mod 7 = 0 Then
n = n + 1
ElseIf a(i,7) Mod 7 = 0 Then
n = n + 1
End If
Next i
lblFirst.Caption = n
Dim i As Integer,n As Integer
For i = 1 To 7
If a(i,1) Mod 7 = 0 Then
n = n + 1
ElseIf a(1,i) Mod 7 = 0 Then
n = n + 1
ElseIf a(7,i) Mod 7 = 0 Then
n = n + 1
ElseIf a(i,7) Mod 7 = 0 Then
n = n + 1
End If
Next i
lblFirst = n
For i = 1 To 7
sum = sum + a(1,i) + a(i,1) + a(7,i) + a(i,7)
Next
sum = sum - a(1,7) - a(1,7) - a(7,1) - a(7,7)
lblSecond = sum
我觉得应该一样啊可是运行出来不对呢
VB编程题:统计7*7数组四周元素之和及四周元素中能够被7整除的元素的个数,并在标签中显示.Sum = 0For i = 1 To 7Sum = Sum + a(1,i)Next iFor i = 1 To 7Sum = Sum + a(7,i)Next iFor i = 2 To 6Sum = Sum + a(i,1)Next iFor i =
你的与标准的确实有区别.计算和的基本上是一样的.但是求被7整除的数的个数,这两段都是求的“不完全个数”,他们之间还有些不同,但均不是题目中要求的东西.
结论:你的答案和标准答案均是错误的.