计算机2级.docx
- 文档编号:5868815
- 上传时间:2023-01-01
- 格式:DOCX
- 页数:40
- 大小:1.04MB
计算机2级.docx
《计算机2级.docx》由会员分享,可在线阅读,更多相关《计算机2级.docx(40页珍藏版)》请在冰豆网上搜索。
计算机2级
OptionBase1DimArr1(20)AsInteger
DimArr2(20)AsIntegerDimSumasInteger
SubReadData1()
OpenApp.Path&"\"&"datain1.txt"ForInputAs#1
Fori=1To20Input#1,Arr1(i)
NextIClose#1EndSubSubReadData2()
OpenApp.Path&"\"&"datain2.txt"ForInputAs#1Fori=1To20Input#1,Arr2(i)
NextiClose#1EndSub
SubWriteData(FilenameAsString,NumAsInteger)
OpenApp.Path&"\"&FilenameforOutputAs#1
Print#1,NumClose#1EndSub
PrivateSubC1_Click()
ReadData1
ReadData2EndSubPrivateSubC2_Click()
Dimarr3(20)AsInteger
Sum=0Fori=1To20
arr3(i)=Arr1(i)-Arr2(i)Sum=Sum+arr3(i)NextPrintSumEndSubPrivateSubC3_Click()WriteData"dataout.txt",Sum
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()
DimiAsInteger
i=18000Doi=i-1
LoopUntilisprime(i)Text1.Text=IEndSubPrivateSubC2_Click()Open"out5.txt"ForOutputAs#1Print#1,Text1.TextClose#1
PrivateSubC1_Click()
DimtempAsLong
DimiAsInteger,kAsInteger
temp=1
Fork=0To2
IfOp1(k).ValueThen
Fori=1ToVal(Op1(k).Caption)
temp=temp*i
Nexti
Text1.Text=temp
EndIfNextk
PrivateSubCommand1_Click()DimiAsIntegerDimsumAsLongsum=1
Ifn=10Orn=12ThenFori=nTo1Step-1sum=sum*iNext
ElseFori=nTo2Step-1
sum=sum+i
Next
EndIf
Text1.Text=sum
EndSub
1DimArr(100)AsInteDimtempAsIntegerSubReadData()OpenApp.Path&"\"&"datain1.txt"ForInputAs#1
Fori=1To100Input#1,Arr(i)NextIClose#1EndSub
SubWriteData(FilenameAsString,NumAsInteger)OpenApp.Path&"\"&FilenameForOutputAs#1Print#1,NumClose#1
PrivateSubCalc_Click()Text1.Text=""Fori=1To100Step2Text1.Text=Text1.Text&Arr(i)&Space(5)
temp=temp+Arr(i)NextIPrinttempEndSubPrivateSubRead_Click()ReadDataEndSub
PrivateSubSave_Click()WriteData"dataout.txt",tempEndSub
2PrivateSubCalc_Click()Text1.Text=""Fori=1To100IfArr(i)Mod3=0Then
Text1.Text=Text1.Text&Arr(i)&Space(5)temp=temp+Arr(i)EndIfNexti
PrinttempEndSub
PrivateSubRead_Click()ReadDataEndSub
PrivateSubSave_Click()WriteData"dataout.txt",tempEndSub
100个整数下届为1奇数元素显示在文本框中,求和并显示第二种是100个整数可以被3整除的显示并求和!
第三种100整数该数组中大于等于50的元素在文本框显示,并求和显示在窗体上
3PrivateSubCalc_Click()Text1.Text=""Fori=1To100IfArr(i)>=50Then
Text1.Text=Text1.Text&Arr(i)&Space(5)temp=temp+Arr(i)EndIfNextIPrinttempEndSubPrivateSubRead_Click()ReadDataEndSub
PrivateSubSave_Click()WriteData"dataout.txt",tempEndSub
第四种100个整数下标为偶数的元素显示在文本框中,求合并显示
PrivateSubCalc_Click()Fori=1To100IfiMod2=0ThenText1.Text=Text1.Text&Arr(i)&Space
(2)
sum=sum+Arr(i)EndIfNextiPrintsumEndSub
PrivateSubForm_Load()Text1.Text=""EndSub
PrivateSubRead_Click()ReadDataEndSub
PrivateSubSave_Click()WriteData"dataout.txt",sumEndSub
第五种100个整数数组中小于50的元素在文本框中显示,并求和显示
PrivateSubCalc_Click()Fori=1To100IfArr(i)<50ThenText1.Text=Text1.Text&Arr(i)&Space
(2)
sum=sum+Arr(i)EndIfNextIPrintsumEndSub
PrivateSubRead_Click()ReadDataEndSub
PrivateSubSave_Click()WriteData"dataout.txt",sumEndSub
3,7,11计算5000以内能被该数整除的所有数之和,放在Text1中PrivateSubC1_Click()IfCb1.Text=3Thendivide(3)ElseIfCb1.Text=7Thendivide(7)Elsedivide(11)Endif
PrivateSubdivide(xAsInteger)DimiAsIntegerDimtempAsLong
Fori=1To5000IfiModx=0Thentemp=temp+IEndIfNextIText1.Text=tempEndsub
1一个命令按钮一个文本框0-1000能被5或7整出的整数个数显示
SubSaveData()OpenApp.Path&"\"&"outtxt.txt"ForOutputAs#1Print#1,Text1.TextClose#1EndSub
FunctionFun()DimtempAsIntegerDimiAsIntegerFori=0To1000IfiMod5=0oriMod7=0Then
temp=temp+1EndIfNextIFun=tempEndFunction
PrivateSubCommand1_Click()d=Fun()Text1.Text=dSaveDataEndSub
2在0-100一个命令按钮一个文本框不能被7整除的所有整数的和在文本框显示
FunctionFun()DimiAsIntegerDimtempAsIntegerFori=0To100IfiMod7<>0Then
temp=temp+IEndIfNextIFun=tempEndFunction
3在0-1000一个命令按钮一个文本框不能被7整除的所有整数的个数显示在文本框
FunctionFun()DimiAsIntegerDimtempAsIntegerFori=0To1000IfiMod7<>0Then
temp=temp+1EndIfNextItext1.text=temp
4在0-200一个命令按钮一个文本框能被3整除的所有整数的和显示在文本框
FunctionFun()DimsumAsInteger,iAsIntegerFori=0To200IfiMod3=0Thensum=sum+I
EndIfNextIText1.Text=sumEndFunction
5在0-100一个命令按钮一个文本框所有偶数的平方和,显示在文本框
FunctionFun()DimiAsInteger,sumAsLongFori=0To100IfiMod2=0Thensum=sum+i*i
EndIfNextIText1.Text=sumEndFunction
PrivateSubCommand1_Click()
Image1.Picture=LoadPicture(App.Path&"\Misc34.ico")EndSub
PrivateSubCommand2_Click()
Image1.Picture=LoadPicture(App.Path&"\Misc37.ico")EndSub
PrivateSubCommand3_Click()
Image1.Picture=LoadPicture("")EndSub
PrivateSubDir1_Change()
File1.Path=Dir1.PathEndSub
PrivateSubDrive1_Change()
Dir1.Path=Drive1.DriveEndSub
PrivateSubFile1_Click()
Label2.Caption=File1.FileName
EndSub
OptionBase1Dima(5,8)AsSingle,athlete(5)AsString*8
PrivateSubCommand1_Click()DimchAsStringText1=""
OpenApp.Path&"\in5.dat"ForInputAs#1Fork=1To5
Input#1,chathlete(k)=chText1=Text1&ch&""
Forj=1To8Input#1,cha(k,j)=Val(ch)
Text1=Text1&ch&""Next
Text1=Text1&Chr(13)&Chr(10)NextkClose#1EndSub
PrivateFunctiongetmark(nAsInteger)AsSingle
s=a(n,1)maxnum=sminnum=sFork=2To7
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机
![提示](https://static.bdocx.com/images/bang_tan.gif)