100分(回复满意加50)问几道VB的题目。能答的就答吧。是我考试的题库。希望不要出错~~还有要写清题号哦~

2024年12月05日 07:37
有3个网友回答
网友(1):

1.1301
Private Sub Command1_Click()
s = 0
For i = 100 To 999
A = i \ 100
B = i \ 10 Mod 10
c = i Mod 10
If A <> B And B <> c And c <> A And i = A ^ 3 + B ^ 3 + c ^ 3 Then
s = s + i
End If
Next i
Print s
End Sub
2.12
Private Sub Command1_Click()
Dim f As Boolean
s = 0
For i = 100 To 666
A = i \ 100
B = i \ 10 Mod 10
c = i Mod 10
If (B + c) Mod 10 = A Then
f = True
End If
For x = 2 To i - 1
If i Mod x = 0 Then
f = False
Exit For
End If
Next x
If f Then
s = s + 1
End If
Next i
Print s
End Sub
3.62730
Private Sub Command1_Click()
s = 0
For i = 10 To 500
If i Mod 2 = 0 Then
s = s + i
End If
Next i
Print s
End Sub
4.31800
Private Sub Command1_Click()
s = 0
For i = 200 To 1000
If i Mod 3 = 0 And i Mod 5 = 0 Then
s = s + i
End If
Next i
Print s
End Sub
5.6
Private Sub Command1_Click()
n = 0
For i = 0 To 9
For j = o To 9
For k = o To 9
If (i * 100 + j * 10 + k) + (k * 100 + j * 10 + i) = 1333 Then
n = n + 1
End If
Next k
Next j
Next i
Print n
End Sub
6.19731
Private Sub Command1_Click()
s = 0
For i = 101 To 999 Step 2
a = i \ 100
b = i \ 10 Mod 10
c = i Mod 10
If (a + b + c) Mod 15 = 0 Then
s = s + i
End If
Next i
Print s
End Sub
7.26
Private Sub Command1_Click()
n = 0
For i = 100 To 650
If i Mod 3 = 0 And i Mod 7 = 0 Then
n = n + 1
End If
Next i
Print n
End Sub
8.25
Private Sub Command1_Click()
n = 2
Dim a(30) As Long
Dim i As Integer
a(1) = 1: a(2) = 1
For i = 3 To 30
a(i) = a(i - 1) + a(i - 2)
If a(i) < 100000 Then
n = n + 1
End If
Next i
Print n
End Sub
9.9227465
Private Sub Command1_Click()
Dim a(35) As Long
Dim i As Integer
a(1) = 1: a(2) = 1
For i = 3 To 35
a(i) = a(i - 1) + a(i - 2)
Next i
Print a(35)
End Sub
10.80
Private Sub Command1_Click()
n = 0
For i = 2000 To 9999
a = i \ 1000
b = i \ 100 Mod 10
c = i \ 10 Mod 10
d = i Mod 10
If a = d And b = c Then
n = n + 1
End If
Next i
Print n
End Sub
11.1953
Private Sub Command1_Click()
n = 0: s = 0
While s < 2000
n = n + 1
s = s + n
Wend
If s > 2000 Then
s = s - n
Else
s = s
End If
Print s
End Sub

网友(2):

1.
153 370 371 407
代码:
Private Sub Command1_Click()
For i = 100 To 999
If Left(i, 1) <> Right(i, 1) And Left(i, 1) <> Mid(i, 2, 1) And Right(i, 1) <> Mid(i, 2, 1) Then
If i = Val(Left(i, 1)) ^ 3 + Val(Right(i, 1)) ^ 3 + Val(Mid(i, 2, 1)) ^ 3 Then Text1 = Text1 & Space(1) & i
End If
Next
End Sub

2.
101 211 239 257 293 349 367 431 523 541 569 587
代码:
Private Sub Command1_Click()
For i = 100 To 666
If Val(Left(i, 1)) = (Val(Right(i, 1)) + Val(Mid(i, 2, 1))) Mod 10 Then
For j = 1 To i
If i Mod j = 0 Then n = n + 1
Next
If n = 2 Then Text1 = Text1 & Space(1) & i
n = 0
End If
Next
End Sub

3.
62730
代码:
Private Sub Command1_Click()
Dim n As Long
For i = 10 To 500
If i Mod 2 = 0 Then n = n + i
Next
Text1 = n
End Sub

4.
31800
代码:
Private Sub Command1_Click()
Dim n As Long
For i = 200 To 1000
If i Mod 3 = 0 And i Mod 5 = 0 Then n = n + i
Next
Text1 = n
End Sub

6.
14985
代码:
Private Sub Command1_Click()
For i = 100 To 999
If i Mod 2 <> 0 And (Val(Right(i, 1)) + Val(Mid(i, 2, 1)) + Val(Right(i, 1))) Mod 15 = 0 Then n = n + i
Next
Text1 = n
End Sub

5.
6 个
代码:
Private Sub Command1_Click()
For i = 0 To 9
For j = 0 To 9
For k = 0 To 9
If Val(i & j & k) + Val(k & j & i) = 1333 Then n = n + 1
Next
Next
Next
Text1 = n
End Sub

7.
26个
代码:
Private Sub Command1_Click()
Dim n As Long
For i = 100 To 650
If i Mod 3 = 0 And i Mod 7 = 0 Then n = n + 1
Next
Text1 = n
End Sub

8.9题 不懂

10.
80个
代码:
Private Sub Command1_Click()
Dim n As Long
For i = 2000 To 9999
If i = Val(StrReverse(i)) Then n = n + 1
Next
Text1 = n
End Sub

11.
1953
代码:
Private Sub Command1_Click()
Dim i As Integer
Dim n As Integer
Do
n = n + 1
If i + n < 2000 Then
i = i + n
Else
Text1 = i
Exit Do
End If
Loop
End Sub

网友(3):

1.
dim i,j,k,sum
for i=1 to 9
for j=0 to 9
for k=0 to 9
if i<>j and i<>k and j<>k and (i*100+j*10+k)=(i^3+j^3+k^3) then sum=sum+i*100+j*10+k
next k
next j
next i
msgbox sum

2.
dim i,j,a,b,c,f,sum
for i=100 to 666
a=i\100
b=(i-a*100)\10
c=i-a*100-b*10
if (b+c) mod 10=a then
f=true
for j=2 to i-1
if i mod j=0 then f=false:exit for
next j
if f then sum=sum+1
next i
msgbox sum

3.
dim i,sum
for i=10 to 500 step 2
sum=sum+i
next
msgbox sum

4.
dim i,sum
for i=200 to 1000
if i mod 3+i mod 5=0 then sum=sum+i
next
msgbox sum

5.
dim i,j,k,a
for i=0 to 9
for j=0 to 9
for k=0 to 9
if i*100+j*10+k+k*100+j*10+i=1333 then a=a+1
next k
next j
next i
msgbox a

6.
dim i,j,k,sum
for i=1 to 9
for j=0 to 9
for k=1 to 9 step 2
if (i+j+k) mod 15=0 then sum=sum+i
next k
next j
next i
msgbox sum

7.
dim i,j
for i=100 to 650
if i mod 3+i mod 7=0 then j=j+1
next
msgbox j

10.
dim i,j
for i=2000 to 9999
if left(cstr(i),2)=right(cstr(i),1) & mid(cstr(i),3,1) then j=j+1
next
msgbox j

11.
dim i,sum
i=0
do
i=i+1
sum=sum+i
loop while sum<2000
msgbox sum-i

第9和第8题回头查下资料再做