<p>2.下列程序是先产生20个不同的随机数,并存于数组a中,然后用比较法(冒泡法)值数据按升序排序输出,请补充完程序。</p><p>Private Sub Form Click()</p><p>Dim a(1 To 20) As Integer, i,j, t, x, yes</p><p>For i=1 To 20</p><p>Do</p><p>x= Int(Rnd *90)+10</p><p>yes=0</p><p>For j=1 To ( 填空1)</p><p>If x= a(j) Then yes =1: Exit For</p><p>Next j</p><p>Loop While (填空2)</p><p>a (i)=(填空3)</p><p>Next i</p><p>For i=1 To 19</p><p>For (填空4) To 20</p><p>If a(i) > a(j) Then (填空5)</p><p>Next j</p><p>Next i</p><p>For i =1 To 20</p><p>Print a(i);</p><p>Next i</p><p>End sub</p><p> </p><p>下面的程序是产生100个[0,99]范围内的随机整数,统计个位上的数字分别为1,2,3,4,5,6,7,8,9,0的数的个数。</p><p>Public Sub Calculate()</p><p>Dim x(1 To 10) As Integer, A(1 To 100)As Integer</p><p>Dim P As Integer, J As Integer</p><p>For J =1 To 100</p><p>A(J)=(填空6)</p><p>P=A(J) - Int(A(J) / 10 )*10</p><p>If P =0 Then (填空7)</p><p>X(P)=X(P)+1</p><p>Next J</p><p>Form1. Print"个位数的个数”</p><p>For J =1 To 10</p><p>(填空8)</p><p>If J =10 Then (填空9)</p><p>Form1. Print "个位数是” &Ps& "有”& X(J) &"有个数"</p><p>Next J</p><p></p><p>End sub</p><p><br></p>
vb 数组题
发布时间:2020-04-19 10:11