100分(回覆滿意加50)問幾道VB的題目。能答的就答吧。是

時間 2021-06-13 09:11:56

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.6private 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.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=0do

i=i+1

sum=sum+i

loop while sum<2000

msgbox sum-i

第9和第8題回頭查下資料再做