欢迎来到天天文库
浏览记录
ID:34389838
大小:118.55 KB
页数:6页
时间:2019-03-05
《高一信息会考》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、《算法与程序设计》单元复习一.程序设计(写出实现流程图虚线框部分3.的程序代码)/输入一个实数a/b=ab=-a4.2.5.(开始)s—O,i—1/输入x/7.己知n个数,编程求这n个数的(1)总和(2)平均值(3)最大值(4)最小值(5)正数和负数的个数cl=0,c2=0/输入x/NxoO?Ncl二cl+1c2As附录:参考答案第一题:PrivateSubCommandl_Click()DimaAsIntegerDimbAsIntegera=InputBox(n请输入数据aH)Ifa<0Thenb二Elseb=aEndIfPrintbEndSub第二题:PrivateSubCommand
2、2_Click()DimxAsIntegerDimyAsIntegera=800:b=1000x=InputBox(n请输入数据xH)Ifx3、=100sum=sum+1/ii=i+1LoopPrintsumEndSub第五题:PrivateSubCommand5_Click()DimiAsInteger,sAsInteger,xAsSingles=0:i=1DoWhilei<=5X=InputBox(n请输入数据xH)Ifx>0ThenS=S+XEndIfi=i+1LoopPrintsEndSub第六题:PrivateSubCommand6_Click()DimxAsSingle,clAsInteger,Integercl=0:c2=0DoWhilei<5x=InputBox(n请输入数据xH)Ifx<>0ThenIfx<0Th4、encl=cl+1Elsec2=c2+1EndIfEndIfi=i+1LoopPrintcl,c2EndSub第六题(数组人PrivateSubCommand7_Click()Dimx(lTo5)AsIntegerDimclAsInteger,c2AsIntegerFori=1To5x(i)=InputBox("请输入第"&i&据:”)Ifx(i)<>0ThenIfx(i)<0Thencl=cl+1Elsec2=c2+1EndIfEndIfNextiPrintcl,c2EndSub第七题(1):PrivateSubCommand8_Click()DimsumAsSingle,iAsInte5、gerDimnAsInteger,xAsIntegersum=0i=1n=InputBox(,,n:H)DoWhilei<=nx=InputBox(nx:H)sum=sum+xi=i+1LoopPrintsumEndSub第七题(2):PrivateSubCommand9_Click()DimsumAsSingle,iAsIntegerDimnAsInteger,xAsIntegersum=0i=1n=InputBox(nn:f,)DoWhilei<=nx=InputBox(Hx:H)sum=sum+xi=i+1LoopPrintsum/nEndSub第七题(3):PrivateSubCo6、mmandlO_CIick()Dimd(lTo100)AsIntegerDimiAsInteger,tempAsInteger,jAsIntegern=InputBox(H请输入数据:”)Fori=1Tond(i)=InputBox「请输入第“&i&”个数据L)NextFori=2TonForj=nToiStep-1Ifd(j)7、gleDimiAsInteger,nAsIntegern=InputBox(Hi#输入数据n:H)X=InputBox(n请输入数据x:M)i=1max=xDoWhileimaxThenmax=xEndIfi=i+1LoopPrintmaxEndSub第七题(4):PrivateSubCommandll_Click()Dimd(lTo100)AsIntegerDimi
3、=100sum=sum+1/ii=i+1LoopPrintsumEndSub第五题:PrivateSubCommand5_Click()DimiAsInteger,sAsInteger,xAsSingles=0:i=1DoWhilei<=5X=InputBox(n请输入数据xH)Ifx>0ThenS=S+XEndIfi=i+1LoopPrintsEndSub第六题:PrivateSubCommand6_Click()DimxAsSingle,clAsInteger,Integercl=0:c2=0DoWhilei<5x=InputBox(n请输入数据xH)Ifx<>0ThenIfx<0Th
4、encl=cl+1Elsec2=c2+1EndIfEndIfi=i+1LoopPrintcl,c2EndSub第六题(数组人PrivateSubCommand7_Click()Dimx(lTo5)AsIntegerDimclAsInteger,c2AsIntegerFori=1To5x(i)=InputBox("请输入第"&i&据:”)Ifx(i)<>0ThenIfx(i)<0Thencl=cl+1Elsec2=c2+1EndIfEndIfNextiPrintcl,c2EndSub第七题(1):PrivateSubCommand8_Click()DimsumAsSingle,iAsInte
5、gerDimnAsInteger,xAsIntegersum=0i=1n=InputBox(,,n:H)DoWhilei<=nx=InputBox(nx:H)sum=sum+xi=i+1LoopPrintsumEndSub第七题(2):PrivateSubCommand9_Click()DimsumAsSingle,iAsIntegerDimnAsInteger,xAsIntegersum=0i=1n=InputBox(nn:f,)DoWhilei<=nx=InputBox(Hx:H)sum=sum+xi=i+1LoopPrintsum/nEndSub第七题(3):PrivateSubCo
6、mmandlO_CIick()Dimd(lTo100)AsIntegerDimiAsInteger,tempAsInteger,jAsIntegern=InputBox(H请输入数据:”)Fori=1Tond(i)=InputBox「请输入第“&i&”个数据L)NextFori=2TonForj=nToiStep-1Ifd(j)7、gleDimiAsInteger,nAsIntegern=InputBox(Hi#输入数据n:H)X=InputBox(n请输入数据x:M)i=1max=xDoWhileimaxThenmax=xEndIfi=i+1LoopPrintmaxEndSub第七题(4):PrivateSubCommandll_Click()Dimd(lTo100)AsIntegerDimi
7、gleDimiAsInteger,nAsIntegern=InputBox(Hi#输入数据n:H)X=InputBox(n请输入数据x:M)i=1max=xDoWhileimaxThenmax=xEndIfi=i+1LoopPrintmaxEndSub第七题(4):PrivateSubCommandll_Click()Dimd(lTo100)AsIntegerDimi
此文档下载收益归作者所有