全文预览

vb文件题型分析

上传者:幸福人生 |  格式:doc  |  页数:9 |  大小:135KB

文档介绍
mpAsString,iAsIntegerOpen"C:\data.txt"ForInputAs#1Do(26)?WhileNotEOF(l)或UntilEOF(l)k=k+1ReDimPreserves(k)(27)Input#1,s(k)List1.Additems(k)LoopClose#1temp=TextlCallsort(temp,s)Fori=1ToUBound(s)List2.Additems(i)NextiEndSubPrivateSubsort(tempAsString,st()AsString)DimlowAsInteger,highAsInteger,midAsIntegerDimiAsIntegerlow=1:high=UBound(st)ReDimPreservest(UBound(st)+1)Iftemp<st(1)Then?'放置最左边Fori=UBound(st)-1To1Step-1st(i+1)=st(i)Nextist(l)=tempExitSubEndIfIftemp>st(high)Then?'放置最右边st(UBound(st))=tempExitSubEndIfDoWhilelow<=highmid=(low+high)/2Iftemp>st(mid)Andtemp<st(mid+1)Then?'放置正中间Fori=UBound(st)・1Tomid+1Step-1(28)st(i+1)=st(i)Nexti(29)st(mid+1)=tempExitDoElselftemp<st(mid)Then(30)hiph=midElselow=mid+1EndIfLoopEndSub答案:WhileNotEOF(1)或UntilEOF(1)Input#1,s(k)st(i+1)=st(i)st(mid+1)=temphigh=mid

收藏

分享

举报
下载此文档