急求vb6.0编写程序题(1)编写程序,从键盘输入一个三位的正整数,计算并输出这个三位数的逆序数,如输入581,输出185。 (2)编写程序,根据从键盘输入的Taxi行驶里程数,计算出相应的收费金额。Taxi的收费标准为:起步价8元(含5公里行程),5公里以上12公里以内,每公里加收1.2元,12公里以上每公里再加收1.5元。(3)编程程序,从键盘输入一个小于7的正整数m,求m!+(m+1)! +(m+2)!...+9!,并输出
2019-04-13
急求vb6.0编写程序题
(1)编写程序,从键盘输入一个三位的正整数,计算并输出这个三位数的逆序数,如输入581,输出185。
(2)编写程序,根据从键盘输入的Taxi行驶里程数,计算出相应的收费金额。Taxi的收费标准为:起步价8元(含5公里行程),5公里以上12公里以内,每公里加收1.2元,12公里以上每公里再加收1.5元。(3)编程程序,从键盘输入一个小于7的正整数m,求m!+(m+1)! +(m+2)!...+9!,并输出
优质解答
1.
Private Sub command1_click()
Dim a As Integer, b As Integer
a = CInt(InputBox("输入一个三位的正整数"))
If a >= 100 And a <= 999 Then
b = (a Mod 10) * 100 + (a \ 10 Mod 10) * 10 + a \ 100
MsgBox b
Else
MsgBox "输入有误!"
End If
End Sub
2.
Private Sub command1_click()
Dim a As Single, b As Single
a = Val(InputBox("输入Taxi行驶里程数(公里)"))
Select Case a
Case Is < 5
b = 8
Case 5 To 12
b = 8 + (a - 5) * 1.2
Case Else
b = 8 + (12 - 5) * 1.2 + (a - 12) * 1.5
End Select
MsgBox b
End Sub
3.
Private Sub command1_click()
Dim m As Integer, i As Integer, s As Double
m = CInt(InputBox("输入一个小于7的正整数"))
If m > 0 And m < 7 Then
For i = 0 To 9
s = s + jc(m + i)
Next
MsgBox s
Else
MsgBox "输入有误!"
End If
End Sub
Function jc(n As Integer) As Double
jc = 1
For i = 2 To n
jc = jc * i
Next
End Function
1.
Private Sub command1_click()
Dim a As Integer, b As Integer
a = CInt(InputBox("输入一个三位的正整数"))
If a >= 100 And a <= 999 Then
b = (a Mod 10) * 100 + (a \ 10 Mod 10) * 10 + a \ 100
MsgBox b
Else
MsgBox "输入有误!"
End If
End Sub
2.
Private Sub command1_click()
Dim a As Single, b As Single
a = Val(InputBox("输入Taxi行驶里程数(公里)"))
Select Case a
Case Is < 5
b = 8
Case 5 To 12
b = 8 + (a - 5) * 1.2
Case Else
b = 8 + (12 - 5) * 1.2 + (a - 12) * 1.5
End Select
MsgBox b
End Sub
3.
Private Sub command1_click()
Dim m As Integer, i As Integer, s As Double
m = CInt(InputBox("输入一个小于7的正整数"))
If m > 0 And m < 7 Then
For i = 0 To 9
s = s + jc(m + i)
Next
MsgBox s
Else
MsgBox "输入有误!"
End If
End Sub
Function jc(n As Integer) As Double
jc = 1
For i = 2 To n
jc = jc * i
Next
End Function