计算机二级所有大题.docx

上传人:b****6 文档编号:5920258 上传时间:2023-01-02 格式:DOCX 页数:35 大小:295.22KB
下载 相关 举报
计算机二级所有大题.docx_第1页
第1页 / 共35页
计算机二级所有大题.docx_第2页
第2页 / 共35页
计算机二级所有大题.docx_第3页
第3页 / 共35页
计算机二级所有大题.docx_第4页
第4页 / 共35页
计算机二级所有大题.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

计算机二级所有大题.docx

《计算机二级所有大题.docx》由会员分享,可在线阅读,更多相关《计算机二级所有大题.docx(35页珍藏版)》请在冰豆网上搜索。

计算机二级所有大题.docx

计算机二级所有大题

1

SubReadData2(OpenApp.Path&"\"&"datain2.txt"ForInputAs#1Fori=1To2Input#1,Arr2(i)NextiClose#1EndSub

SubWriteData(FilenameAsString,NumAsInteger)OpenApp.Path&"\"&FilenameForOutputAs#1Print#1,NumClose#1EndSub

PrivateSubCommand1_Click(EndSub

PrivateSubc1_Click()CallReadData1CallReadData2EndSub

PrivateSubc2_Click()Dimarr3(20)AsInteger,sumAsIntegersum=0

Fori=1To20arr3(i)=Arr1(i)-Arr2(i)sum=sum+arr3(i)Nexti

Printsum

CallWriteData("dataout.txt",sum)

EndSub

2DimstepyAsInteger'纵向移动增量

DimstepxAsInteger'横向移动增量

ConstLEFT_BUTTON=1

PrivateSubForm_MouseDown(ButtonAsInteger,ShiftAsInteger,xAsSingle,yAsSingle)

Dimx0AsInteger,y0AsInteger,aAsSingle,radiusAsInteger

radius=Shape1.Width/2'圆的半径

IfButton=LEFT_BUTTONThen

x0=Shape1.Left+radius'圆心的x坐标

y0=Shape1.Top+radius'圆心的y坐标

Ifx=x0Then

stepy=Sgn(y-y0)*50

stepx=0

Else

a=(y-y0)/(x-x0)'斜率

stepx=Sgn(x-x0)*50

stepy=a*stepx

IfAbs(stepy)>Abs(stepx)Then

stepy=Sgn(y-y0)*50

stepx=stepy/a

EndIf

EndIf

Timer1.Enabled=True

Else

Timer1.Enabled=False

EndIf

EndSub

PrivateSubTimer1_Timer()

Shape1.MoveShape1.Left+stepx,Shape1.Top+stepy

EndSub

3)

PrivateSubCommand2_Click()

'需要考生编写的内容

l=Val(Text1.Text)

SelectCasel

CaseIs>=2000

t=0.9

CaseIs>=1500

 

t=0.92

CaseIs>=1000

t=0.95

CaseIs>=500

t=0.98

CaseElse

t=1

EndSelect

y=Int(l*t*0.3)

Text2.Text=Str(y)

EndSub

PrivateSubList1_Click()

'需要考生编写的内容

Text1.Text=a(List1.ListIndex+1)

EndSub

4

PrivateSubCommand2_Click()

'要求考生编写的程序

DimiAsInteger,p(5)

Fori=1To5

p(i)=getmark(i)

Nexti

gj=p

(1)

j=1

Fori=1To5

Ifp(i)>gjThen

gj=p(i)

j=i

EndIf

Nexti

Text2.Text=athlete(j)

Text3.Text=Str(gj)

EndSub

5

参考代码:

DimiAsInteger

DimnAsInteger

n=Val(Text1.Text)3

IfnMod2<>0Then

MsgBox"请输入偶数!

"

ExitSub

EndIf

Fori=3Ton/2

IfIsPrime(i)AndIsPrime(n-i)Then

Label1.Caption=i

Label2.Caption=n-i

ExitFor

EndIf

Next

6

PrivateSubCommand2_Click()

'需考生编写

maxl=0

c=0

Sum=0

t=""

Fori=1ToLen(s)

ch=Mid(s,i,1)

Ifch<>""Then

t=t+ch

Else

IfLen(t)>maxlThen

maxl=Len(t)

EndIf

Sum=Sum+Len(t)

c=c+1

EndIf

Nexti

Text1.Text=Str(CInt(Sum/c))

Text2.Text=Str(maxl)

Endsub

 

7

PrivateSubCommand2_Click()

'考生编写程序开始

'======================================

Fori=1To30

c(i)=a(i)

c(30+i)=b(i)

Nexti

Fori=1To59

Forj=1To60-i

Ifc(j)>c(j+1)Then

t=c(j)

c(j)=c(j+1)

c(j+1)=t

EndIf

Nextj

Nexti

 

'=========================================

'考生编写程序结束

 

8

PrivateSubCommand2_Click()

'考生编写

Dima(26)AsInteger

Fori=1ToLen(s)

ch=Mid(s,i,1)

Ifch>="a"Andch<="z"Then

ch=Chr(Asc(ch)-32)

EndIf

Ifch>="A"Andch<="Z"Then

a(Asc(ch)-Asc("A")+1)=a(Asc(ch)-Asc("A")+1)+1

EndIf

Nexti

Max=a

(1)

j=1

Fori=1To26

Ifa(i)>MaxThen

Max=a(i)

j=i

EndIf

Nexti

Text1.Text=Chr(Asc("a")+j-1)

Text2.Text=Str(Max)

EndSub

 

9'

以下Function过程用于判断字符串是否为回文

Functionfoundhuiwen(pAsString)

'考生编写

Fori=1ToInt(Len(p)/2)

IfMid(p,i,1)<>Mid(p,Len(p)-i+1,1)Then

ExitFunction

EndIf

Nexti

foundhuiwen=True

EndFunction

 

10

PrivateSubCommand2_Click()

'考生需要编写的程序

s=Text1.Text

Text1.Text=""

Fori=1ToLen(s)

ch=Mid(s,i,1)

Ifch="E"Orch="N"Orch="T"Then

ch=LCase(ch)

ElseIfch="e"Orch="n"Orch="t"Then

ch=UCase(ch)

EndIf

Text1.Text=Text1.Text+ch

Nexti

EndSub

 

11

PrivateSubCommand1_Click()

Text4=""

a=Val(Text1)

b=Val(Text2)

n=Val(Text3)

Text4=Text4&a&""&b

k=2

DoWhilek

c=a*b

k=k+1

Ifc<10Then

Text4=Text4&""&c

a=b

b=c

Else

d=c\10

Text4=Text4&""&d

a=d

k=k+1

Ifk<=nThen

d=cMod10

Text4=Text4&""&d

b=d

EndIf

EndIf

Loop

EndSub

 

12

OptionBase1

PrivateSubForm_Click()

ConstN=5

ConstM=5

Dimmat(N,M)

Dimi,j

OpenApp.Path&"\"&"datain.txt"ForInputAs#1

Fori=1ToN

Forj=1ToM

Input#1,mat(i,j)

Nextj

Nexti

Close#1

Print

Print"初始矩阵为:

"

Print

Fori=1ToN

Forj=1ToM

PrintTab(5*j);mat(i,j);

Nextj

Print

Nexti

Print:

Print

Print"右上-左下对角线上的数为:

"

Fori=1ToN

Forj=1ToM

Ifi+j=6Then

PrintTab(5*i);mat(i,j);

EndIf

Nextj

Nexti

EndSub

13

PrivateSubCommand2_Click()

'考生编写

Fori=1To12

Sum=0

Forj=1To10

Sum=Sum+a(i,j)

Nextj

s(i)=Int(Sum/10)

Nexti

EndSub

 

14

PrivateSubCommand1_Click()

'========以下考生编写程序开始=======

a59=0

a69=0

a79=0

a89=0

a99=0

Fori=1Ton

SelectCasearr(i)

CaseIs<60

a59=a59+1

CaseIs<70

a69=a69+1

CaseIs<80

a79=a79+1

CaseIs<90

a89=a89+1

CaseElse

a99=a99+1

EndSelect

Nexti

Text1.Text=Str(n)

Text2.Text=Str(a59)

Text3.Text=Str(a69)

Text4.Text=Str(a79)

Text5.Text=Str(a89)

Text6.Text=Str(a99)

 

'======"考生编写程序结束"=======================

EndSub

15

DimwhichAsInteger

PrivateSubcopy_Click()

Ifwhich=1Then

Text3.Text=Text1.Text

ElseIfwhich=2Then

Text3.Text=Text2.Text

EndIf

EndSub

PrivateSubcut_Click()

Ifwhich=1Then

Text3.Text=Text1.Text

Text1.Text=""

ElseIfwhich=2Then

Text3.Text=Text2.Text

Text2.Text=""

EndIf

EndSub

PrivateSubedit_Click()

Ifwhich=1Then

IfText1.Text=""Then

cut.Enabled=False

copy.Enabled=False

Else

cut.Enabled=True

copy.Enabled=True

EndIf

ElseIfwhich=2Then

IfText2.Text=""Then

cut.Enabled=False

copy.Enabled=False

Else

cut.Enabled=True

copy.Enabled=True

EndIf

EndIf

IfText3.Text=""Then

paste.Enabled=False

Else

paste.Enabled=True

EndIf

EndSub

PrivateSubpaste_Click()

Ifwhich=1Then

Text1.Text=Text1.Text+Text3.Text

ElseIfwhich=2Then

Text2.Text=Text2.Text+Text3.Text

EndIf

EndSub

PrivateSubText1_GotFocus()'本过程的作用是:

当焦点在Text1中时,which=1

which=1

EndSub

PrivateSubText2_GotFocus()'本过程的作用是:

当焦点在Text2中时,which=2

which=2

EndSub

16

PrivateSubC1_Click()

IfText1.Text="123456"Then

Text1.Text="口令正确"

Text1.PasswordChar=""

Else

Text2.Text=Text2.Text-1

IfText2.Text>0Then

MsgBox"第"&(3-Text2.Text)&"次口令错误,请重新输入"

Else

MsgBox"3次输入错误,请退出"

Text1.Enabled=False

EndIf

EndIf

EndSub

17

PrivateSubCommand2_Click()

Dimb(100)AsInteger

num=0

IfLen(Text1.Text)=0Then

MsgBox"请先执行“读数据”功能!

"

Else

'考生编写(功能:

生成b数组,且按从小到大顺序排序)

'注意:

请务必将数组b的元素个数存入变量num中

Fori=1To100

Ifa(i)Mod3=0Then

num=num+1

b(num)=a(i)

EndIf

Nexti

Fori=1Tonum-1

Forj=1Tonum-i

Ifb(j)>b(j+1)Then

t=b(j)

b(j)=b(j+1)

b(j+1)=t

EndIf

Nextj

Nexti

'以下程序段将已排序的b数组显示在Text2中

Fori=1Tonum

Text2.Text=Text2.Text+Str(b(i))+Space

(2)

Nexti

EndIf

EndSub

18

OptionBase1

DimArr(100)AsInteger

DimsumAsInteger

SubReadData()

OpenApp.Path&"\"&"datain1.txt"ForInputAs#1

Fori=1To100

Input#1,Arr(i)

Nexti

Close#1

EndSub

SubWriteData(FilenameAsString,NumAsInteger)

OpenApp.Path&"\"&FilenameForOutputAs#1

Print#1,Num

Close#1

EndSub

PrivateSubcalc_Click()

Text1.Text=""

Fori=1To100

IfArr(i)Mod3=0Then

Text1.Text=Text1.Text+Str(Arr(i))+Space

(2)

sum=sum+Arr(i)

EndIf

Nexti

Printsum

EndSub

PrivateSubread_Click()

CallReadData

EndSub

PrivateSubsave_Click()

CallWriteData("dataout.txt",sum)

EndSub

19

PrivateFunctionisprime(aAsInteger)AsBoolean

DimflagAsBoolean

flag=True

b%=2

DoWhileb%<=Int(a/2)Andflag

IfInt(a/b%)=a/b%Then

flag=False

Else

b%=b%+1

EndIf

Loop

isprime=flag

EndFunction

PrivateSubC1_Click()

DimaAsInteger

a=15000

DoWhilea>=15000

a=a+1

Ifisprime(a)Then

Text1.Text=Str(a)

ExitDo

EndIf

Loop

EndSub

PrivateSubC2_Click()

OpenApp.Path+"\out5.txt"ForOutputAs#1

Print#1,Text1.Text

Close#1

EndSub

20

PrivateSubCommand2_Click()

'================================================

'算法:

'1)令i指向第1个数,j指向最后1个数,并先暂存最后一个数;

'2)检查第i个数是否为偶数,若不是,再检查下一个,直到第i个是

'偶数,则把此偶数放到第j个位置,j向前移1个位置;

'3)检查第j个数是否为奇数,若不是,再检查前一个,直到第j个是

'奇数,则把此奇数放到第i个位置,i向后移1个位置;

'4)重复2)、3),直到i=j

'5)把开始暂存的数放到i的位置

'=================================================

Dimi%,j%,temp%,flagAsBoolean

i=0

j=9

temp=Text1(j)

flag=True

While(i

IfflagThen

IfText1(i)Mod2=0Then

Text1(j)=Text1(i)

j=j-1

flag=Notflag

Else

i=i+1

EndIf

Else

IfText1(j)Mod2=1Then

Text1(i)=Text1(j)

i=i+1

flag=Notflag

Else

j=j-1

EndIf

EndIf

Wend

Text1(i)=temp

EndSub

21

PrivateSubCommand1_Click()

'========考生编写程序开始========

Sum=0

jg=0

bjg=0

Fori=1Ton

Sum=Sum+arr(i)

Ifarr(i)>=60Then

jg=jg+1

Else

bjg=bjg+1

EndIf

Nexti

Avg=Sum/n

Text1.Text=Str(n)

Text2.Text=Str(Avg)

Text3.Text=Str(bjg)

Text4.Text=Str(jg)

 

'==========考生编写程序结束==============

EndSub

22

OptionBase1

PrivateSubCommand1_Click()

Dims(35)AsLong

s

(1)=1

s

(2)=1

Fori=3To35

s(i)=s(i-1)+s(i-2)

Nexti

IfOp1(0).ValueThen

Text1.Text=s(30)

ElseIfOp1

(1).ValueThen

Text1.Text=s(33)

Else

Text1.Text=s(35)

EndIf

EndSu

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育 > 政史地

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1