全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1(1)public sub qiuz1() dim x, y, z as double x = val(inputbox(请输入x) y = val(inputbox(请输入y) select case x case is y and (y 0) z = x / y end select debug.print z为: & str(z)end sub(2)public sub qiuz() dim x, y, z as double x = val(inputbox(请输入x) y = val(inputbox(请输入y) if x y and y 0) then z = x / y end ifdebug.print z为: & str(z)end sub2. public sub qiugen() dim a, b, c, d1, d2 as double a = val(inputbox(请输入a) do while (a = 0) msgbox (输入错误) a = val(inputbox(请重新输入a) loop b = val(inputbox(请输入b) c = val(inputbox(请输入c)if b * b - 4 * a * c 0 then debug.print 无解 else d1 = (-1 * b + sqr(b * b - 4 * a * c) / (2 * a) d2 = (-1 * b - sqr(b * b - 4 * a * c) / (2 * a) debug.print 第一个根为: & str(d1) debug.print 第二个根为: & str(d2) end if end sub3. public sub dayinweek() dim x as integer x = val(inputbox(请输入x) do while (x 6) msgbox (输入错误) x = val(inputbox(请重新输入x) loop if x = -1 then exit sub elseif x = 0 then debug.print 星期天 elseif x = 1 then debug.print 星期一 elseif x = 2 then debug.print 星期二 elseif x = 3 then debug.print 星期三 elseif x = 4 then debug.print 星期四 elseif x = 5 then debug.print 星期五 elseif x = 6 then debug.print 星期六 end if end sub4. public sub xinglifee() dim nianli, zhongliang, goli, feiyong as double nianli = val(inputbox(请输入年龄) zhongliang = val(inputbox(请输入重量) goli = val(inputbox(请输入百公里数) if nianli 18 then rem 未成年 if zhongliang 10 then rem 未成年免费 feiyong = 0 else rem 未成年收费 if goli * 100 mod 100 = 0 then rem 百公里整除收费 feiyong = goli * (zhongliang - 10) * 0.2 else rem 百公里不整除收费 feiyong = (int(goli) + 1) * (zhongliang - 10) * 0.2 end if end if else rem 成年 if zhongliang 20 then rem 成年免费 feiyong = 0 else rem 成年收费 if goli * 100 mod 100 = 0 then rem 百公里整除收费 feiyong = goli * (zhongliang - 20) * 0.2 else rem 百公里不整除收费 feiyong = (int(goli) + 1) * (zhongliang - 20) * 0.2 end if end if end if debug.print 应收费用为: & str(feiyong)end sub5. (1)public sub qiuhe() dim i, j, sum, sumnei as integer sum = 0 for i = 1 to 10 sumnei = 0 for j = 1 to i sumnei = sumnei + j next sum = sum + sumnei nextdebug.print 和为: & str(sum)end sub(2)public sub qiujiechenghe() dim i, j, sum, sumnei as double sum = 0 for i = 1 to 10 sumnei = 1 for j = 1 to i sumnei = sumnei * j next sum = sum + sumnei next debug.print 阶乘的和为: & str(sum)end sub6. public sub qiu6() dim i, sum as integer sum = 0 for i = 100 to 200 if (i mod 3 = 0) and (i mod 5 = 0) then sum = sum + 1 debug.print i= & str(i) end if nextdebug.print 被3整除又被5整除数的个数为: & str(sum)end sub7.(2)public sub dayinxing2() dim i, j as integer for i = 1 to 9 debug.print next debug.print tab(20); * for i = 3 to 6 debug.print tab(20 - i + 1); for j = 1 to i debug.print *; next debug.print nextend sub(3)public sub dayinxing() dim i, j as integer for i = 1 to 9 debug.print next for i = 1 to 5 debug.print tab(21 - i); * nextend sub8. public sub qiudefen() dim i, sum, defen, score(1 to 10), zhongfen, maxs, mins as double sum = 0 for i = 1 to 10 score(i) = val(inputbox(请输入第 & str(i) & 个分数) sum = sum + score(i) nextmaxs = score(1) mins = score(1) for i = 2 to 10 if maxs score(i) then mins = score(i) end if next defen = (sum - maxs - mins) / 8 debug.print 最后得分为: & str(defen)end sub9. public sub qiusushu() dim i, j, sum as integer dim flag as boolean sum = 0 for i = 2 to 100 flag = true for j = 2 to int(i / 2) if (i mod j = 0) then flag = false exit for end if next if flag then sum = sum + i debug.print 素数为: & str(i) end if nextdebug.print 全部素数和为: & str(sum)end sub10,, public sub shuixianhua() dim i, g, s, b as integer for i = 0 to 999 g = i mod 10 s = i 10 mod 10 b = i 100 if i = g 3 + s 3 + b 3 then debug.print 水仙花数为: & str(i) end if nextend sub12. public sub lixi() dim i, sum as double sum = 10000 i = 0 do while sum n then maxs = m mins = n else maxs = n mins = m end if for i = maxs to 1 step -1 if (m mod i = 0) and (n mod i = 0) then debug.print 最大公约数为: & str(i) exit for end if next for i = maxs to m * n if (i mod m = 0) and (i mod n = 0) then debug.print 最小公倍数为: & str(i) exit for end if nextend sub5.public sub 求和() dim i, s as integer i = 1 s = 0 do while i = 10 debug.print i s = s + (1 + i) * i) / 2 debug.print s i = i + 1 loop debug.print s的值为: & str(s)end sub7. public sub 求星型输出() dim i, j as integer for i = 1 to 9 debug.print next for i = 1 to 4 debug.print tab(20); *; for j = 1 to 2 * i - 2 debug.print *; next j debug.print next
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 深度解析(2026)《GBT 3630-2017铌板材、带材和箔材》
- 《JBT 10812-2018立式斜流泵》专题研究报告
- 2026年法律职业资格考试商法股东分红权规则卷含解析
- 2026高一数学下册第一单元第一次月考含答案及解析
- 《JBT 10577-2006电磁吸盘》专题研究报告
- JBT 10401.1-2004离网型风力发电机组制动系统
- 湖南中考:英语重点基础知识点大全
- 2026年党建知识竞赛试题及答案(三)
- 2026年国际重要湿地生态特征变化及预警响应技术测试
- 2026年乡镇干部直播电商营销技巧知识试题
- 中考英语模拟试卷命题指南与标准
- 2026年血站上岗证测试卷【巩固】附答案详解
- 2025-2026学年天津市河西区七年级下学期期中数学试卷(含答案)
- 2026年钳工技能鉴定考核综合提升练习试题(考点梳理)附答案详解
- GA 53-2025爆破作业人员资格条件和管理要求
- 《年历、月历中的信息》教案-2025-2026学年苏教版小学三年级数学下册
- JCT 2786-2023 水泥工业用V型静态选粉机 (正式版)
- 《红楼梦》各章思维导图(共80张图)
- GB/T 7094-2016船用电气设备振动(正弦)试验方法
- GB/T 20631.2-2006电气用压敏胶粘带第2部分:试验方法
- 知行合一读书分享课件
评论
0/150
提交评论