VB练习题7道,七道全讲完才行一、Private Sub Command1_Cilck()Dim a(4,4)For i = 1 To 4For j = 1 To 4Next jNext iFor j = 3 To 4For j = 3 To 4Print a(j,i);Next jEnd Sub9 1210 13二、Private Sub Form _Click()Dim a(10),p(3)As Integerk = 5For i

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/28 12:02:03
VB练习题7道,七道全讲完才行一、Private Sub Command1_Cilck()Dim a(4,4)For i = 1 To 4For j = 1 To 4Next jNext iFor j = 3 To 4For j = 3 To 4Print a(j,i);Next jEnd Sub9 1210 13二、Private Sub Form _Click()Dim a(10),p(3)As Integerk = 5For i
xV[oG+GHwk'`"qi%TG);+T) "@ ű/:y_虙wח4Uޙٙ}Mw{uoލ6nûzw㍷1>s?k7>+_Y\>gEt^>cO~QPԳv,%MSeS|win yowޘ}r_*U<G+YՁns$Lڡ=TW +Us_FFxr|pNIă!qFKFld)Wmsb&c3RRڏbRlzuJkRp=?G ?S# h;wT N[E*hHGek@H B57VA,t_U@d ҇?nRÔ-/}*V*#b Ge"/+׋׋g >wU2> JЉXQ2LhL1 FyO6Cx槸OFF//␦? !*>FRcOo78Ȓ \

VB练习题7道,七道全讲完才行一、Private Sub Command1_Cilck()Dim a(4,4)For i = 1 To 4For j = 1 To 4Next jNext iFor j = 3 To 4For j = 3 To 4Print a(j,i);Next jEnd Sub9 1210 13二、Private Sub Form _Click()Dim a(10),p(3)As Integerk = 5For i
VB练习题7道,七道全讲完才行
一、
Private Sub Command1_Cilck()
Dim a(4,4)
For i = 1 To 4
For j = 1 To 4
Next j
Next i
For j = 3 To 4
For j = 3 To 4
Print a(j,i);
Next j
End Sub
9 12
10 13
二、
Private Sub Form _Click()
Dim a(10),p(3)As Integer
k = 5
For i = 1 To 10
a(i)= i
Next i
For i = 1 To 3
p(i)= a( i * i )
Next i
For i = 1 To 3
k = k + p(i) * 2
Next i
Print k
End Sub
33
三、
Option Base 1
Prinvate Sub Command1_Click()
Dim a
s = 0
a = Array(1,2,3,4)
j = 1
For i = 4 To 1 Step-1
s=s + a(i)*j
j=j * 10
Next i
Print s
End Sub
答案是1234
四、
Option Base 1
Private Sub Command1_Click()
Dim a As Variant
a= Array(1,2,3,4,5)
Sum = 0
For i=1 To 5
Sum = sum+a(i)
Next i
x= Sum/5
For i =1 To 5
If a(i)>x Then Print a(i);
Next i
End Sub 4 5
五、
Private Sub Form_Click()
Dim arr1(10,10)As Integer
Dim i,j As Integer
For i = 1 To 3
For j = 2 To 4
arr1(i,j)=i + j
Next j
Next i
Text1.Text = arr1(2,3) + arr1(3,4)
End Sub 12
六、
Option base 1
Prinvate Sub Command1_Click()
Dim a%(3,3)
For i = 1 To 3
For j = 1 To 3
a(i,j)=i*j
Print a(i,j);" ";
Next j
Print
Next i
End Sub 1 2 3
2 4 6
3 6 9
七、
Dim a
i=0
a=Array(1,-2,9,0,-1,9)
DO
k=a(i)
For m = 10 To k Step -2
n=k+m
Next m
Print n+m
i=i+1
Loop While Abs(m+n)27
3 -8 27

VB练习题7道,七道全讲完才行一、Private Sub Command1_Cilck()Dim a(4,4)For i = 1 To 4For j = 1 To 4Next jNext iFor j = 3 To 4For j = 3 To 4Print a(j,i);Next jEnd Sub9 1210 13二、Private Sub Form _Click()Dim a(10),p(3)As Integerk = 5For i
一、你写的程序是不是不全,有些问题;
二、Private Sub Form _Click()
Dim a(10),p(3)As Integer
k = 5 'k=5For i = 1 To 10
a(i)= i
Next i '定义a1=1,a2=2,.a10=10
For i = 1 To 3p(i)= a( i * i ) '定义p1=a1*a1,p2=a2*a2,p3=a3*a3Next iFor i = 1 To 3
k = k + p(i) * 2 ' k=(5+p1*2)+((5+p1*2)+p2*2)+(((5+p1*2)+p2*2)+p3*2)Next i
Print kEnd Sub答案是 33
三、
Option Base 1Prinvate Sub Command1_Click()
Dim a
s = 0
a = Array(1,2,3,4) ‘a(0)=1,a(1)=2,a(2)=3,a(3)=4
j = 1 ’下一句应该修改为 For i = 3 To 0 Step-1
For i = 4 To 1 Step-1 ’i从4到1,每次递减1
s=s + a(i)*j ‘i应该从3到0 才对
j=j * 10 ' i=4,j=1 i=3,j=10 i=2,j=100 i=1,j=1000
Next i ' i=3 s=(0+a4*1)+a3*10 .i=1 ...
Print s
End Sub
答案是1234
四、
Option Base 1Private Sub Command1_Click()
Dim a As Variant
a= Array(1,2,3,4,5) ‘a0=1,a1=2,a2=3,a3=4,a4=5
Sum = 0For i=1 To 5 '和三一样的问题:应该是 for i=0 to 4
Sum = sum+a(i) 'i=1 sum =0+1 i=2 sum=1+2.i=5 sum=1+2+3+4+5=15
Next i
x= Sum/5 'x=3
For i =1 To 5
If a(i)>x Then
Print a(i); '输出a1到a5 大于x的值,就是 4,5
Next i
End Sub 答案是 4 5
五、
Private Sub Form_Click()
Dim arr1(10,10)As Integer ‘定义数据组合区域
Dim i,j As Integer
For i = 1 To 3
For j = 2 To 4
arr1(i,j)=i + j
Next j
Next i ‘定义:i = 1 To 3 j = 2 To 4 arr1(i,j)=i+j 既是:arr1(2,3)=2+3=5 arr1(3,4)=7
Text1.Text = arr1(2,3) + arr1(3,4) '所以答案是12
End Sub 答案是 12
六、
Option base 1Prinvate Sub Command1_Click()Dim a%(3,3)
For i = 1 To 3
For j = 1 To 3 ’定义数组区间i = 1 To 3
j = 1 To 3
a(i,j)=i*jPrint a(i,j);" "; ’ a%(1,1)=1*1=1 a%(1,2)=1*2=2,.a%(3,3)=3*3=9
Next j
Print
Next i '分别输出 对应就是:1,2,3,2,4,6,3,6,9
End Sub 答案是 1 2 3
2 4 6
3 6 9
七、
Dim a
i=0
a=Array(1,-2,9,0,-1,9) ‘a(0)=1,a(1)=-2,a(2)=9,.a(5)=9
DO
k=a(i) 'i开始已经定义为0 所以下面 DO 到loop 的语句中 i 依次+1
For m = 10 To k Step -2 ‘从10 到1 每次减2
n=k+m ’i=0,k=1,n=1+2,
Next m ‘m=0时 停止,此时n=1+2 ,m=0
Print n+m 'i=0,n+m=3+0
i=i+1 依次.i=1,2,3,4,5
Loop While Abs(m+n)27 ’ 如果Abs(m+n)27 ,i依次增加1 当m+n=27时下走,程序结束
答案是 3 -8 27