大一计算机课后习题答案_第1页
大一计算机课后习题答案_第2页
大一计算机课后习题答案_第3页
大一计算机课后习题答案_第4页
大一计算机课后习题答案_第5页
已阅读5页,还剩56页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

3.4PrivateSubCommand1_Click()Image1.Width=Image1.Width*1.2Image1.Height=Image1.Height*1.2EndSubPrivateSubCommand2_Click()Image1.Width=Image1.Width/1.2Image1.Height=Image1.Height/1.2EndSubPrivateSubCommand3_Click()Image1.Width=Form1.WidthImage1.Height=Form1.HeightEndSubPrivateSubForm_Load()Image1.Left=0Image1.Top=0Image1.Picture=LoadPicture(App.Path&"\back.jpg")EndSub3.5DimmleftAsLongPrivateSubCommand1_Click()Timer1.Enabled=TrueEndSubPrivateSubCommand2_Click()Timer1.Enabled=FalseEndSubPrivateSubTimer1_Timer()mleft=Label1.Left+100Ifmleft+Label1.Width>Picture1.WidthThenmleft=0EndIfLabel1.Left=mleftEndSub4.1PrivateSubForm_Load()Form1.ShowSum=0Fori=1To4a=InputBox("请输入数值型数据")Sum=Sum+aave=Sum/4NextPrintSum;aveEndSub4.3PrivateSubCommand1_Click()a=5b=2.5c=7.8pi=3.14159265y=pi*a*b/a+b*cPrintyEndSub4.4PrivateSubCommand1_Click()a=Val(Text1.Text)tian=a\86399xiaoshi=(a-tian*86400)\1439fenzhong=(a-tian*86400-xiaoshi*1440)\59miao=a-tian*86400-xiaoshi*1440-fenzhong*60Text2.Text=tian&"天"&xiaoshi&"小时"&fenzhong&"分钟"&miao&"秒"EndSub4.5PrivateSubCommand1_Click()ConstgAsSingle=9.81t=InputBox("请输入t的值")v0=InputBox("请输入v0的值")s=1/2*g*t*t+v0*tPrintFormat(s,"0.##")EndSub4.6PrivateSubCommand1_Click()Sum=0Fori=2To100Step2Sum=Sum+iNextLabel1.FontSize=20Label1.Caption="2+4+6+……+100="&SumEndSub4.7PrivateSubCommand1_Click()Doa=InputBox("请输入三角形的第一条边长")a1=Val(a)Ifa1=-1ThenEndEndIfb=InputBox("请输入三角形的第二条边长")b1=Val(b)Ifb1=-1ThenEndEndIfc=InputBox("请输入三角形的第三条边长")c1=Val(c)Ifc1=-1ThenEndEndIfIf(a1+b1>c1)And(a1+c1>b1)And(b1+c1>a1)Thens=a1+b1+c1ExitDoElseError1=MsgBox("您输入的数据不能构成三角形")EndIfLoopLabel4.Caption="您输入的边长分别为:"&a1&","&b1&","&c1&""&"面积为:"&sEndSub4.8PrivateSubCommand1_Click()IfText1.Text<>""Thena=Text1.TextSelectCaseaCaseIs<=200s=0CaseIs<=400s=(a-200)*0.03CaseIs<5000s=200*0.03+(a-400)*0.04CaseIs>=5000s=(400-200)*0.03+(5000-400)*0.04+(a-5000)*0.05EndSelectText2.Text=sElseerror1=MsgBox("请输入您的收入!")EndIfEndSubPrivateSubForm_Load()Text2.Locked=TrueEndSubPrivateSubText1_Change()IfNotIsNumeric(Text1.Text)Thenerror1=MsgBox("请输入数字")EndIfEndSub4.9PrivateSubText1_Change()a=Text1.TextSelectCaseaCase0Label2.Caption="休息"Text1.SelStart=0Text1.SelLength=1Case1,3Label2.Caption="讲计算机课"Text1.SelStart=0Text1.SelLength=1Case2,4Label2.Caption="讲程序设计课"Text1.SelStart=0Text1.SelLength=1Case5Label2.Caption="进修英语"Text1.SelStart=0Text1.SelLength=1Case6Label2.Caption="政治学习"Text1.SelStart=0Text1.SelLength=1CaseElseError1=MsgBox("您确认退出程序?",52,"确认")IfError1=6ThenEndElseText1.SelStart=0Text1.SelLength=1EndIfEndSelectEndSub4.10PrivateSubCommand1_Click()Fori=1To9PrintTab(30-3*i);Forj=1ToiPrintj;NextjFork=i-1To1Step-1Printk;NextkPrintNextiEndSub4.11PrivateSubCommand1_Click()Fori=1To30Forj=iTo30Fork=jTo30Ifi*i+j*j=k*kThenPrintTab(10);i,Tab(23);j,Tab(36);kEndIfNextk,j,iEndSub4.12PrivateSubForm_Click()DimmAsInteger,nAsIntegerm=CInt(Val(InputBox("请输入计算范围的初值")))n=CInt(Val(InputBox("请输入计算范围的终值")))Fori=mTons=0Forj=1Toi-1IfiModj=0Thens=s+jEndIfNextjIfs=iThenPrintiNextiEndSub4.13PrivateSubForm_Click()DimaAsString,cAsStringDimbAsIntegera=InputBox("请输入学生姓名")b=InputBox("请输入学生成绩")SelectCasebCaseIs<=39c="Fail"CaseIs<=49c="Poor"CaseIs<=59c="Fair"CaseIs<=79c="Good"CaseElsec="VeryGood"EndSelectPrint"姓名:"&aPrint"成绩:"&bPrint"评语:"&cEndSub4.14PrivateSubCommand1_Click()DimaAsIntegera=Val(Text1.Text)Ifa<10Ora>99Thenerror1=MsgBox("您输入的不是两位正整数,请重新输入")ElseFori=10To99a1=a\10+(aMod10)*10i1=i\10+(iMod10)*10If(a+i=a1+i1)And(a1>9)And(i1>9)ThenLabel2.Caption=Label2.Caption&Chr(13)&a&"+"&i&"="&a1&"+"&i1Form1.Height=Label2.Height+Label2.Top+1000EndIfNextEndIfEndSub4.15Dima,b,sAsDoubleDimflag,comAsIntegerPrivateSubCommand1_Click()Ifflag=0ThenText1.Text=Text1.Text&Command1.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command1.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand2_Click()Ifflag=0ThenText1.Text=Text1.Text&Command2.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command2.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand3_Click()Ifflag=0ThenText1.Text=Text1.Text&Command3.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command3.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand4_Click()Ifflag=0ThenText1.Text=Text1.Text&Command4.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command4.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand5_Click()Ifflag=0ThenText1.Text=Text1.Text&Command5.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command5.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand6_Click()Ifflag=0ThenText1.Text=Text1.Text&Command6.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command6.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand7_Click()Ifflag=0ThenText1.Text=Text1.Text&Command7.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command7.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand8_Click()Ifflag=0ThenText1.Text=Text1.Text&Command8.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command8.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand9_Click()Ifflag=0ThenText1.Text=Text1.Text&Command9.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command9.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand10_Click()Ifflag=0ThenText1.Text=Text1.Text&Command10.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command10.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand11_Click()Ifflag=0ThenText1.Text=Text1.Text&Command11.Captiona=Val(Text1.Text)ElseText1.Text=""flag=0Text1.Text=Text1.Text&Command11.Captiona=Val(Text1.Text)EndIfEndSubPrivateSubCommand12_Click()SelectCasecomCase1a=b+aText1.Text=aflag=1Case2a=b-aText1.Text=aflag=1Case3a=b*aText1.Text=aflag=1Case4a=b/aText1.Text=aflag=1EndSelectEndSubPrivateSubCommand13_Click()b=aflag=1com=1EndSubPrivateSubCommand14_Click()b=aflag=1com=2EndSubPrivateSubCommand15_Click()b=aflag=1com=3EndSubPrivateSubCommand16_Click()b=aflag=1com=4EndSub5.1PrivateSubForm_Click()Dima(1To20)Fori=1To20a(i)=InputBox("请输入第"&i&"个元素")NextiFori=1To20Printa(i);"";NextiPrintFori=1To10t=a(i)a(i)=a(21-i)a(21-i)=tNextiFori=1To20Printa(i),NextiEndSub5.2PrivateSubForm_Click()Dima(1To10,1To10)Fori=1To10Forj=1To10Ifi=jThena(i,j)=1ElseIfi+j=11Thena(i,j)=1Elsea(i,j)=0EndIfNextjNextiFori=1To10Forj=1To10Printa(i,j);NextjPrintNextiEndSub5.3PrivateSubForm_Click()Dima()AsIntegern=InputBox("请输入n")m=InputBox("请输入m")Print"数组为"&n&"行"&m&"列"ReDima(n,m)Fori=1TonForj=1Toma(i,j)=InputBox("请输入第"&i&"行"&j&"列")NextjNextiFori=1TonForj=1TomPrinta(i,j);NextjPrintNextis=0Fori=1TonForj=1Toms=s+a(i,j)NextjNextiv=s/(n*m)Print"平均值为:"&vFori=1TonForj=1TomIfa(i,j)>vThenPrint"元素:"&a(i,j)&"行号:"&i&"列号:"&jEndIfNextjNextiEndSub5.4PrivateSubForm_Click()Dima(1To50,1To4)AsIntegerFori=1To50Forj=1To4a(i,j)=Int(Rnd*90+10)NextjNexti'显示满足条件的行Fori=1To50Forj=1To4Ifa(i,j)>90ThenFork=1To4Printa(i,k)&"";NextkPrintExitForEndIfNextjNexti'显示完整数组Fori=1To50Forj=1To4Printa(i,j)&"";NextjPrintNextiEndSub5.5PrivateSubForm_Click()DimnAsInteger,mAsIntegerDima()AsIntegern=InputBox("请输入行数n")m=InputBox("请输入列数m")ReDima(1Ton,1Tom)Fori=1TonForj=1Toma(i,j)=InputBox("请输入第"&i&"行"&j&"列的元素")NextjNextiFori=1TonForj=1TomPrintFormat(a(i,j),"000")&"";NextjPrintNextian_num=0Fori=1Tonhmax=a(i,1)lhao=1Forj=1TomIfa(i,j)>hmaxThenhmax=a(i,j)lhao=jEndIfNextjlmin=a(i,lhao)Fork=1TonIfa(k,lhao)<lminThenlmin=a(k,lhao)EndIfNextkIflmin=hmaxThenPrint"鞍点为:"&i&"行"&lhao&"列"an_num=an_num+1EndIfNextiIfan_num=0ThenPrint"无鞍点"EndSub5.6PrivateSubForm_Click()Dima(1To3,1To3)AsIntegerDimb(1To3,1To3)AsIntegerDimc(1To3,1To3)AsIntegerFori=1To3Forj=1To3a(i,j)=Int(Rnd*90+10)b(i,j)=Int(Rnd*90+10)NextjNextiPrint"数组A:"Fori=1To3Forj=1To3Printa(i,j)&"";NextjPrintNextiPrint"数组B:"Fori=1To3Forj=1To3Printb(i,j)&"";NextjPrintNextiFori=1To3Forj=1To3c(i,j)=a(i,j)+b(i,j)NextjNextiPrint"数组C:"Fori=1To3Forj=1To3Printc(i,j)&"";NextjPrintNextiEndSub5.7PrivateSubForm_Click()Dima(1To10,1To3)DimsAsInteger,avAsIntegerFori=1To10a(i,1)=InputBox("请输入第"&i&"个学生的姓名")a(i,2)=InputBox("请输入第"&i&"个学生的学号")a(i,3)=InputBox("请输入第"&i&"个学生的成绩")NextiPrint"原始数据为:"Print"姓名","学号","成绩"Fori=1To10Forj=1To3Printa(i,j),NextjPrintNextis=0Fori=1To10s=s+a(i,3)Nextiav=s/10Print"平均成绩为:"&avPrint"姓名","学号","成绩","奖金等级"Fori=1To10Ifa(i,3)>av*1.1ThenPrinta(i,1),a(i,2),a(i,3),"一等奖"ElseIfa(i,3)>av*1.05ThenPrinta(i,1),a(i,2),a(i,3),"二等奖"EndIfNextiEndSub5.8PrivateSubForm_Click()Dima(1To10,1To4)Fori=1To10a(i,1)=InputBox("请输入第"&i&"个学生的姓名")a(i,2)=Val(InputBox("请输入第"&i&"个学生的语文成绩"))a(i,3)=Val(InputBox("请输入第"&i&"个学生的数学成绩"))a(i,4)=(a(i,2)+a(i,3))/2NextiPrint"姓名","语文","数学","平均分"Fori=1To10Forj=1To4Printa(i,j),NextjPrintNextiFori=10To2Step-1Forj=1Toi-1Ifa(j,4)<a(j+1,4)Thent=a(j,1)a(j,1)=a(j+1,1)a(j+1,1)=tt=a(j,2)a(j,2)=a(j+1,2)a(j+1,2)=tt=a(j,3)a(j,3)=a(j+1,3)a(j+1,3)=tt=a(j,4)a(j,4)=a(j+1,4)a(j+1,4)=tEndIfNextjNextiPrint"姓名","语文","数学","平均分"Fori=1To10Forj=1To4Printa(i,j),NextjPrintNextiEndSub5.9PrivateSubForm_Click()Dima,b,c(0To5)AsIntegera=Array(2,8,7,6,4,28,70,25)b=Array(79,27,32,41,57,66)Print"A数组的内容:"ForEachxInaPrintx,NextxPrintPrint"B数组的内容:"ForEachxInbPrintx,NextxPrintPrint"C数组的内容:"Fori=0To5c(i)=a(i)+b(i)Printc(i),NextiEndSub5.10PrivateSubForm_Click()Dima(1To4,1To4)AsIntegerFori=1To4Forj=1To4a(i,j)=InputBox("请输入第"&i&"行第"&j&"列的元素")NextjNextiPrint"原始数组:"Fori=1To4Forj=1To4Printa(i,j),NextjPrintNextiPrint"主对角线:"Fori=1To4Printa(i,i),NextiPrintPrint"另一条对角线:"Fori=1To4Printa(i,5-i),NextiPrintFori=1To4s=0Forj=1To4s=s+a(i,j)NextjPrint"第"&i&"行的和为:"&sNextiFori=1To4s=0Forj=1To4s=s+a(j,i)NextjPrint"第"&i&"列的和为:"&sNextiFori=1To4t=a(1,i)a(1,i)=a(3,i)a(3,i)=tNextiFori=1To4t=a(i,2)a(i,2)=a(i,4)a(i,4)=tNextiPrint"成果数组:"Fori=1To4Forj=1To4Printa(i,j),NextjPrintNextiEndSub5.11PrivateSubForm_Click()Dima()DimnAsIntegern=InputBox("请输入人数N")ReDima(1Ton,1To5)Fori=1Tona(i,1)=InputBox("请输入第"&i&"个人的姓名")a(i,2)=InputBox("请输入第"&i&"个人的性别")a(i,3)=InputBox("请输入第"&i&"个人的年龄")a(i,4)=InputBox("请输入第"&i&"个人的文化程度")a(i,5)=InputBox("请输入第"&i&"个人的籍贯")NextiPrint"原始数据:"Print"姓名","性别","年龄","文化程度","籍贯"Fori=1TonForj=1To5Printa(i,j),NextjPrintNextiPrint"查找的成果:"x=6DoWhilex=6sn=InputBox("请输入要查找的人的姓名")Fori=1TonIfsn=a(i,1)ThenForj=1To5Printa(i,j),NextjPrintExitForEndIfNextiIfi>nThenPrint"没有找到该人"x=MsgBox("你与否还要继续查找??",vbInformation+vbYesNo,"提问")LoopEndSub5.12PrivateSubForm_Click()Dima(1To10,1To2)Fori=1To10a(i,1)=CStr(InputBox("请输入运动员号"))a(i,2)=Val(InputBox("请输入成绩"))NextiPrint"原始的次序"Print"运动员号","成绩"Fori=1To10Forj=1To2Printa(i,j),NextjPrintNextiFori=10To2Step-1Forj=1Toi-1Ifa(j,2)>a(j+1,2)Thent=a(j,2)a(j,2)=a(j+1,2)a(j+1,2)=tt=a(j,1)a(j,1)=a(j+1,1)a(j+1,1)=tEndIfNextjNextiPrint"排列的次序"Print"名次","运动员号","成绩"Fori=1To10Printi,Forj=1To2Printa(i,j),NextjPrintNextiEndSub5.13PrivateSubForm_Click()Dima(11,11)Fori=1To11a(i,1)=1a(i,i)=1NextiFori=3To11Forj=2To10a(i,j)=a(i-1,j-1)+a(i-1,j)NextjNextiFori=1To11Forj=1ToiPrintFormat(a(i,j)),NextjPrintNextiEndSub6.4PrivateSubForm_Click()DimiAs

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论