那位大侠帮我做几个VB(Visual Basic)的题目啊,很基础,但我不会
1、求1~100中为5或7的倍数的和。请将结果输出到窗体上,并存入所给变量SUM中。使用While…Wend语句完成程序。2、在窗体上打印如图所示的图形。********...
1、求1~100中为5或7的倍数的和。请将结果输出到窗体上,并存入所给变量SUM中。使用While…Wend语句完成程序。
2、在窗体上打印如图所示的图形。
*
***
*****
*******
3、求sum=1+1+2+3+5+8+13+……+144的和,请将sum结果值输出到窗体上。使用Do…Loop语句完成程序。
4、求3+6+9+12+15+18+…+300的和,将计算结果存入变量sum中,并将结果输出到窗体上。
5、求10~20之间所有素数的乘积并输出到窗体上,将结果存入变量P中。 展开
2、在窗体上打印如图所示的图形。
*
***
*****
*******
3、求sum=1+1+2+3+5+8+13+……+144的和,请将sum结果值输出到窗体上。使用Do…Loop语句完成程序。
4、求3+6+9+12+15+18+…+300的和,将计算结果存入变量sum中,并将结果输出到窗体上。
5、求10~20之间所有素数的乘积并输出到窗体上,将结果存入变量P中。 展开
3个回答
展开全部
1.
Private Sub Command1_Click()
i = 1
While i <= 100
If i Mod 5 = 0 Or i Mod 7 = 0 Then Sum = Sum + i
i = i + 1
Wend
Print Sum
End Sub
2.
Private Sub Command1_Click()
For i = 1 To 7 Step 2
For j = 1 To i
Print "*";
Next
Print
Next
End Sub
3.
Private Sub Command1_Click()
f1 = 1
f2 = 1
Sum = 2
Do
fn = f1 + f2
f1 = f2
f2 = fn
Sum = Sum + fn
Loop Until fn = 144
Print Sum
End Sub
4.
Private Sub Command1_Click()
For i = 3 To 300 Step 3
Sum = Sum + i
Next
Print Sum
End Sub
5.
Private Sub Command1_Click()
P = 1
For i = 10 To 20
For j = 2 To i - 1
If i Mod j = 0 Then Exit For
Next
If j = i Then P = P * i
Next
Print P
End Sub
Private Sub Command1_Click()
i = 1
While i <= 100
If i Mod 5 = 0 Or i Mod 7 = 0 Then Sum = Sum + i
i = i + 1
Wend
Print Sum
End Sub
2.
Private Sub Command1_Click()
For i = 1 To 7 Step 2
For j = 1 To i
Print "*";
Next
Next
End Sub
3.
Private Sub Command1_Click()
f1 = 1
f2 = 1
Sum = 2
Do
fn = f1 + f2
f1 = f2
f2 = fn
Sum = Sum + fn
Loop Until fn = 144
Print Sum
End Sub
4.
Private Sub Command1_Click()
For i = 3 To 300 Step 3
Sum = Sum + i
Next
Print Sum
End Sub
5.
Private Sub Command1_Click()
P = 1
For i = 10 To 20
For j = 2 To i - 1
If i Mod j = 0 Then Exit For
Next
If j = i Then P = P * i
Next
Print P
End Sub
展开全部
你看前两题这样做行不?
第一题:
Dim i As Integer
Dim SUM As Long
i = 0
SUM = 0
While i <= 100
i = i + 1
If (i Mod 5 = 0) Or (i Mod 7 = 0) Then SUM = SUM + i
Wend
第二题:
Dim i As Integer
Dim j As Integer
For i = 1 To 4
For j = 1 To 2 * i - 1
Print "*";
Next j
Print
Next i
第一题:
Dim i As Integer
Dim SUM As Long
i = 0
SUM = 0
While i <= 100
i = i + 1
If (i Mod 5 = 0) Or (i Mod 7 = 0) Then SUM = SUM + i
Wend
第二题:
Dim i As Integer
Dim j As Integer
For i = 1 To 4
For j = 1 To 2 * i - 1
Print "*";
Next j
Next i
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
2.
For i = 1 to 4
For j= 1 to 2*i-1
print "*";
next j
Print
Next i
For i = 1 to 4
For j= 1 to 2*i-1
print "*";
next j
Next i
追问
这也太……
追答
4.
For i=3 to 300 step 3
Sum=sum+i
next i
print sum
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询