求一简单编程,basic语言的
我用的是visualbasic6.0题目如下:输入5个数字abcde在5个数中的运算为加减乘5个数的顺序不变,3个运算符号可重复如a+b+c+d+e=a+b+c+d-e=...
我用的是visual basic 6.0
题目如下:
输入5个数字
a b c d e 在5个数中的运算为加减乘
5个数的顺序不变,3个运算符号可重复
如a+b+c+d+e=
a+b+c+d-e=
a+b+c+d*e=
a+b+c-d+e=
a+b+c-d*e=
。。。。。
a*b*c*d*e=
一共81个结果,输出结果,结果范围为-100~100
程序一定要完整的,答案对的话可以再加分 展开
题目如下:
输入5个数字
a b c d e 在5个数中的运算为加减乘
5个数的顺序不变,3个运算符号可重复
如a+b+c+d+e=
a+b+c+d-e=
a+b+c+d*e=
a+b+c-d+e=
a+b+c-d*e=
。。。。。
a*b*c*d*e=
一共81个结果,输出结果,结果范围为-100~100
程序一定要完整的,答案对的话可以再加分 展开
1个回答
展开全部
建6个text控件,分别命名为text1,text2,text3,text4,text5,text6 。 前5个用于输入a,b,c,d,e 5个数字,第6个用于显示结果序列,记得把第6个文本框的mutiline属性设置为ture。 创建一个按钮,命名Command1,点击开始计算,代码如下:
Dim a, b, c, d, resu, s1, s2, s3, s4, coun As Long
Private Sub Command1_Click()
On Error Resume Next
Text6.Text = ""
coun = 0
a = Int(Text1.Text)
b = Int(Text1.Text)
c = Int(Text1.Text)
d = Int(Text1.Text)
For s1 = 0 To 2 Step 1
For s2 = 0 To 2 Step 1
For s3 = 0 To 2 Step 1
For s4 = 0 To 2 Step 1
DoEvents
Select Case s1
Case 0
resu = a + b
Case 1
resu = a - b
Case 2
resu = a * b
End Select
Select Case s2
Case 0
resu = resu + c
Case 1
resu = resu - c
Case 2
resu = resu * c
End Select
Select Case s3
Case 0
resu = resu + d
Case 1
resu = resu - d
Case 2
resu = resu * d
End Select
Select Case s4
Case 0
resu = resu + e
Case 1
resu = resu - e
Case 2
resu = resu * e
End Select
coun = coun + 1
If resu >= -100 And resu <= 100 Then
Text6.Text = Text6.Text & "第" & Str(coun) & "个数:" & Str(resu) & Chr(13) & Chr(10)
Else
Text6.Text = Text6.Text & "第" & Str(coun) & "个数不在-100~100范围内"& Chr(13) & Chr(10)
End If
Next s4
Next s3
Next s2
Next s1
End Sub
Dim a, b, c, d, resu, s1, s2, s3, s4, coun As Long
Private Sub Command1_Click()
On Error Resume Next
Text6.Text = ""
coun = 0
a = Int(Text1.Text)
b = Int(Text1.Text)
c = Int(Text1.Text)
d = Int(Text1.Text)
For s1 = 0 To 2 Step 1
For s2 = 0 To 2 Step 1
For s3 = 0 To 2 Step 1
For s4 = 0 To 2 Step 1
DoEvents
Select Case s1
Case 0
resu = a + b
Case 1
resu = a - b
Case 2
resu = a * b
End Select
Select Case s2
Case 0
resu = resu + c
Case 1
resu = resu - c
Case 2
resu = resu * c
End Select
Select Case s3
Case 0
resu = resu + d
Case 1
resu = resu - d
Case 2
resu = resu * d
End Select
Select Case s4
Case 0
resu = resu + e
Case 1
resu = resu - e
Case 2
resu = resu * e
End Select
coun = coun + 1
If resu >= -100 And resu <= 100 Then
Text6.Text = Text6.Text & "第" & Str(coun) & "个数:" & Str(resu) & Chr(13) & Chr(10)
Else
Text6.Text = Text6.Text & "第" & Str(coun) & "个数不在-100~100范围内"& Chr(13) & Chr(10)
End If
Next s4
Next s3
Next s2
Next s1
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询