资源描述:
《第6章数组习题参考答案》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、第六章数组习题参考答案6-1请同学上机运行代码。6-2OptionExplicitOptionBase1PrivateSubCommandl_Click()DimiAsInteger,tAsIntegerDima(15)AsIntegerRandomizeFori=1To15a(i)=Int(100*Rnd)Textl=Textl&Str(a(i))NextiFori=1To7t=a(i)a(i)=a(16-i)a(16-i)=tNextiFori=1To15Text2=Text2&Str(a(i))NextiEndSubPrivate
2、SubCommand2_CIick()Textl=,n,Text2=unEndSubPrivateSubCommand3_Click()EndEndSub6-3OptionExplicitDima(20)AsIntegerPrivateSubCommandl_Click()DimiAsIntegerRandomizeFori=1To20a(i)=Int(90*Rnd)+10Textl=Textl&Str(a(i))NextiEndSubPrivateSubCommand2_Click()DimiAsInteger,jAsInteger,
3、fAsBooleanDimnAsIntegerFori=1To20f=TrueForj=i+1To20Ifa(i)=a(j)Thenf=FalseNextjIff=TrueThenn=n+1NextiText2=nEndSubPrivateSubCommand3_Click()Textl=””EndSubPrivateSubCommand4_Click()EndEndSubOptionExplicitDima(20)AsIntegerPrivateSubCommandl_Click()DimiAsIntegerRandomizeFori
4、=1To20a(i)=Int(90*Rnd)+10Textl=Textl&Str(a(i))NextiEndSubPrivateSubCommand2_Click()DimiAsInteger,jAsInteger,maxAsIntegerDimnAsInteger,wAsInteger,pAsIntegerFori=1To20n=0:p=iForj=1To4Ifi>20Thenp=p・20n=n+a(p)NextjIfn>maxThenmax=nw=iEndIfNextiText2=maxPicture1.Printw&”■■“&w+
5、4EndSubPrivateSubCommand3_Click()Textl=EndSubPrivateSubCommand4_Click()EndEndSub6-5■6-5欽组行与列求和374438896781514877192430253128Dima(5,5)AsIntegerPrivateSubCommand1_Click()Fori=1To4Forj=1To5a(i,j)=Int(9*Rnd)+1Picture1.Printa(i,j);NextjPicturel.PrintNextiEndSubPrivateSubComma
6、nd2_Click()Forj=1To5s=0Fori=1To4s=s+a(i,j)NextiTextl=Textl&Str(s)NextjEndSubPrivateSubCommand3_Click()Fori=1To4s=0Forj=1To5s=s+a(i,j)NextjText2=Text2&Str(s)&Chr(13)&Chr(10)NextiEndSubPrivateSubCommand4_Click()Textl=Text2二“”Picturel.CisEndSubPrivateSubCommand5_Click()EndE
7、ndSub91719857474131974884605331831384411463670662916117OptionExplicitPrivateSubCommandl_Click()Dima(5,5),iAsInteger,jAsIntegerDimnAsInteger,mAsInteger,tAsIntegerRandomizeFori=1To5Forj=1To5・1a(i,j)=Int(40*Rnd)*2+10NextjNextiFori=1To5Forj=5To6-iStep-1a(i,j)=Int(40*Rnd)*2+1
8、1NextjNextiFori=1To5Forj=1To5Textl=Text1&Str(a(i,j))NextjTextl=Textl&vbCrLfNextiEndSub6-7同6・46-86-8矩阵求和