全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 机械挂靠公司协议书
- 广东2025年下半年台山市部分事业单位招考易考易错模拟试题(共500题)试卷后附参考答案
- 校园卫生消毒协议书
- 卸货搬运合同协议书
- 山东2025年下半年高密市事业单位招考易考易错模拟试题(共500题)试卷后附参考答案
- 安徽合肥市事业单位招考人员易考易错模拟试题(共500题)试卷后附参考答案
- 宁波市北仑区图书馆编外用工招考易考易错模拟试题(共500题)试卷后附参考答案
- 天津高新技术成果转化中心事业单位招考易考易错模拟试题(共500题)试卷后附参考答案
- 分公司设立的协议书
- 儿子买房合同签协议
- 收割机收割协议合同范本
- 重晶石精深加工生产线项目可行性研究报告
- 八年级语文上册统编版第六单元 课外古诗词诵读(公开课一等奖创新教学设计)
- 泌尿外科教学病例讨论
- 中华人民共和国两用物项出口管制条例考试试卷试题及参考答案
- 2025年综合类-热力司炉工考试-高级热力司炉工历年真题摘选带答案(5卷单选一百题)
- 公司区域协同管理办法
- 人教版九年级上册历史期末复习知识点考点背诵提纲详细版
- 2025至2030中国马铃薯产品行业发展分析及产业运行态势及投资规划深度研究报告
- 园艺植物课程中的思政教育建设探讨
- 电商公司选品管理制度
评论
0/150
提交评论