..Dim a() a=Array(1,3,5,7,9) s=0 For i=1 To 4 s=s*10+a(i) Next i Print s 为啥答案是3579
..Dim a() a=Array(1,3,5,7,9) s=0 For i=1 To 4 s=s*10+a(i) Ne
答案:1 悬赏:0 手机版
解决时间 2021-03-22 17:56
- 提问者网友:不爱我么
- 2021-03-22 04:43
最佳答案
- 五星知识达人网友:西风乍起
- 2021-03-22 06:20
For i = 1 To 4 s = s * 10 + a(i)Next i '对于数组a,为a(0)=1, a(1)=3, a(2)=5, a(3)=7, a(4)=9 'i=1时, s = s * 10 + a(1) = 0 * 10 + 3 = 3 'i=2时, s = s * 10 + a(2) = 3 * 10 + 5 = 35 'i=3时, s = s * 10 + a(3) = 35 * 10 + 7 = 357 'i=4时, s = s * 10 + a(4) = 357 * 10 + 9 = 3579 '在整个For循环中, 类似于作如下操作(其实s等于0,相当于根本就用不上了) 'i=1时,s1 = s * 10 + a(1) = 0 * 10 + a(1) = a(1) 'i=2时,s2 = s1 * 10 + a(2) = a(1) * 10 + a(2) 'i=3时,s3 = s2 * 10 + a(3) = (a(1) * 10 + a(2)) * 10 + a(3) = a(1) * 100 + a(2) * 10 + a(3) 'i=4时,s4 = s3 * 10 + a(4) = (a(1) * 100 + a(2) * 10 + a(3)) * 10 + a(4) = a(1) * 1000 + a(2) * 100 + a(3) * 10 + a(4) '就相当于从千位数到个位数,分别是a(1)、a(2)、a(3)、a(4),就等于3579了
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯