Const n=10 Dim a(1 To n) As Integer Private Sub Command1_Click ( ?。?br />Dim i As Integer,a As Integer,ans As Integer,t As Integer ,讀取每個學(xué)生的買菜時間,依次存儲在數(shù)組a中,代碼略 For i=1 To n-1 k=i For j=n To i+1 Step-1 If
Then k=j Next j If a(i)<>a(k) Then t=a(i):a(i)=a(k):a(k)=t Next i s=0:ans=0 For i=1 To n If Then s=s+a(i):ans=ans+1 Next i Label1.Caption=“共有“+Str(ans)+“個人是愉快的,且參與排隊買菜。“ (1)代碼“Private Sub Commandl_Click ( ?。敝械腃ommand1是
操作1:依次輸入1,11,1 操作1:依次輸入7,9,2 操作2:輸入8 (2)請在橫線處填入合適的代碼。 Const n=10 Dim a(1 To n)As Integer Dim f(1 T on)As Integer'f數(shù)組元素依次表示每段的標(biāo)記值 Dim bk As Integer'bk表示每段的元素個數(shù) Function BL(x As Integer)As Integer'BL函數(shù)返回數(shù)組元素a(x)的段編號 BL=
End Function Private Sub Form_Load ( ?。?br />’讀取數(shù)據(jù),并存儲到數(shù)組a中,代碼略 bk=Int(Sgr(n)) End Sub Private Sub Command1_Click ( ) Dim L As Integer,R As Integer,T As Integer,i As Integer L=Val(Text1.Text):R=Val(Text2.Text):T=Val(Text3.Text) If BL(L)=BL(R)Then For i=L To R a(i)=a(i)+T Next i EIse For i=
a(i)=a(i)+T Next i For i=BL(L)+1 To BL(R)-1 f(i)=f(i)+T Next i For i=(BL(R)-1)*bk+1 To R a(i)=a(i)+T Next i End If End Sub Private Sub Command2_Click ( ?。?br />Dim K As Integer K=Val(Text4.Text) Labe.15.Caption=“經(jīng)過一系列操作后。a(“+Str(K)+“)的值為:“+