编程题题目及答案

上传人:z**** 文档编号:104581268 上传时间:2022-06-10 格式:DOC 页数:7 大小:62.50KB
返回 下载 相关 举报
编程题题目及答案_第1页
第1页 / 共7页
编程题题目及答案_第2页
第2页 / 共7页
编程题题目及答案_第3页
第3页 / 共7页
亲,该文档总共7页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
1. 输入 a, b, c 三个数,按从大到小的次序显示。Private Sub Command1_Click() a 二 Vai(Textl. Text)b 二 Vai(Text2. Text)c 二 Vai(Text3. Text)If ba Then t=a:a=b:b=tIf bc ThenLabel4. Caption二aLabel5. Caption二bLabel6. Caption二cElself c a ThenLabel4. Caption二cLabel5. Caption二aLabel6. Caption二bElseLabel4. Caption二aLabel5. Caption二cLabel6. Caption二bEnd IfEnd SubPrivate Sub Command2_C1ick()End2. 任意输入一个整数,判定该整数的奇偶性。Private Sub Commandl_Click0x 二 Vai(Textl. Text)If x Mod 2=0 ThenLabel2. Caption =是偶数ElseLabel2. Caption =是奇数End IfEnd SubPrivate Sub Command2_C1ick()End3. 编制程序,计算某个学生奖学金的等级,以语文a、数学b、英语c三门功课的成绩为评。Private Sub Commandl_Click 0 a=Val(Textl. Text) b=Val(Text2. Text) c=Val(Text3. Text)If a+b+c=285 Or (a=100 And b=100 And c=80) Or (b=100 And c=100 And a=80) Or (a=100 And c=100 And b=80) ThenLabel5. Caption 等奖Elself a+b+c=270 Or (a=100 And b=75 And c=75) Or (b=100And a=75 And c=75) Or (c=100 And a=75 And b=75) ThenLabel5. Caption 二二等奖Elself a =70 And b 二 70 And c 二 70 ThenLabel5. Caption 三等奖ElseLabel5. Caption= 无End IfEnd SubPrivate Sub Command2_C1ick()EndEnd SubPrivate4. 编制程序,根据用户输入的考试成绩,按表 3-1 分数与等级的对照标准,输出相应的等级, SubCommand 1_C lick ()x 二 Vai(Textl. Text)Select Case xCase Is 二 90Label3. Caption=优秀Case 80 To 89Label3. Caption 二良好Case 70 To 79Label3. Caption 中Case 60 To 69Label3. Caption 二及格Case ElseLabel3. Caption = 不及格End SelectEnd SubPrivate Sub Command2_C1ick()EndEnd Sub5. 计算分段函数:Private Sub Commandl_Click0 x=Val(Textl. Text)Select Case xCase Is 0Label3. Caption=x*x+1Case Is二 1Label3. Caption=3*x 3Case ElseLabel3. Caption=2*x+1End SelectEnd SubPrivate Sub Command2_C1ick()EndEnd Sub6. 公用电话收费标谁如下Private Sub Commandl_Click()x 二 Vai(Textl. Text)If x=3 ThenLabel3. Caption 0. 2 元Elsey=(x-3)*0. 1+0. 2Label3. Caption Format (y, 0. 0 )& 元End SubPrivate Sub Command2_C1ick()EndEnd Sub2. 在图片框中打印九九乘法表。Private Sub Picturel_Click()Dim se As StringPicturel. Print Tab (35); 九九乘法表Picturel. Print Tab (35); For i=1 To 9For j=1 To ise=i & X& j & =& i * jPicturel. Print Tab(jT)*9+1) ;se;Next jPicturel. PrintNext iEnd Sub图4-4Private Sub Command1_C1ick()3. 在列表框中输出1-100之间不能被3整除的数,要求用Do语句实现,j=lDo While j=100If j Mod 300 ThenListl. Additem jEnd Ifj=j+lLoopEnd SubPrivate Sub Command2_C1ick()EndEnd Sub4. 在图片框中打印如图4-6所示的沙漏图形。Private Sub Commandl_ClickOFori 二 1 To 5Picturel. Print Tab (3 * );“ ;For j 二 1 To 17 - i * 3Picturel. Print ;Next jPicturel. Print ;Picturel. PrintNext iPicturel. Print Tab (3 * i) ; ;For i = 5 To 1 Step -1Picturel. Print Tab (3 * i) ; ;For j = 1TO17 - i*3Picturel. Print ;Next jPicturel. Print ;Picturel. PrintNext iEnd SubPrivate Sub Command2_C1ick()EndEnd Sub5. 编程求1 !+2!+3!+?+10!的结果,程序运行界面如图4-7所示Private Sub Commandl_Click()s=0:n=lFor i=1 To 10n= n*is=s+nNext iLabel3. CaptionsEnd SubPrivate Sub Command2_C1ick()EndEnd Sub1. 随机产生10个0? 100之间的正整数,将它们按从大到小的顺序排列Private Sub Commandl_Click0Dim x(l To 10) As IntegerPrintPrint 原始数据:For i = 1 To 10x(i) 二 Int(Rnd * 101)Print x(i);Next iPrint: PrintPrint 排序数据:For i 二 1 To 9For j = i + 1 To 10If x (i) x(j) Then t 二 x(i) x(i)= x(j) x(j) 二 tEnd IfNext jPrint x(i);Next iPrint x(10)End Sub2. 显示出具有N行的“杨辉三角形”。Private Sub Command1_Click()Dim a() As Integer n 二 Vai(Textl. Text)ReDim a(l To n, 1 To n) As IntegerFor i = 1 To na(i, 1)= 1: a(i, i) 二 1Next iFor i = 3 To nFor j = 2 To i - 1 a(i, j)= a(i - 1, j - 1) + a(i - 1, j) Next j Next iFor i = 1 To nFor j = 1 To iPicturel. Print Tab(j * 5 - 4) ; a(i, j);Next j Picturel. Print Next iEnd Sub3. 从 40 分? 100 分随机产生 50 名学生的物理课程考试成绩Dim 成绩(50), 统计(5 To 9) As Integer RandomizeFor i=l To 50 成绩 (i)=Int (Rnd*61) +40 Listl. Additem 成绩 (i) 分段二成绩 (i)10 Select Case 分段 Case 4 To 5 统计 (5)= 统计 (5)+1 Case 6 To 8 统计 ( 分段 ) 二统计 ( 分段 )+1 Case 9 To 10 统计 (9) 二统计 (9)+1 End SelectNext iPicturel. Print分段成绩结果为:Picturel.Print40 - 59的人数Picturel.Print 60 - 69的人数Picturel.Print70 - 79的人数为:Picturel.Print80 - 89的人数为:Picturel.Print90- 100的人数为Picturel. Print/;统计;统计;统计;统计(8);统计(9)End SubPrivate Sub Command2_C1ick()EndEnd Sub09出现的5. 当在文本框中输入任意字母或数字时,单击”统计”按钮,将会在图片柩中打印岀数字字符次数。6. 利用随机数生成矩阵 A (数据不一定相同,要求数据范围在2080之间),求A的转置矩阵5. Private Sub Command1_C1ick()Dim a (4, 4), b (4, 4) As IntegerFor i=1 To 4For j=1 To 4a(i, j)=lnt (Rnd*61+20)b(j, i)=a(i, j)Picturel. Print a(i, j)Next jPicturel. PrintNext iFor i 二 1 To 4For j 二 1 To 4Picture2. Print b (i, j)Next jPicture2. PrintNext iEnd SubPrivate Sub Command2_C1ick()EndEnd Sub6. Private Sub Commandl_Click(lndex As Integer)Picturel. CisPicturel. FillStyle=6Select Case IndexCase 0Picturel. Print画直线Picturel. Line (2, 2)-(7, 7)Case 1Picturel. Print画矩形Picturel. Line (2, 2)-(7, 7),BFCase 2Picturel. Print画圆Picturel. Circle (4. 5, 4. 5), 3. 5, 1Case ElseEndEnd SelectEnd SubPrivate Sub Form_Load()Picturel. Scale (0, 0)-(10, 10) 设置坐标系End Sub
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 办公文档 > 活动策划


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!