




已阅读5页,还剩17页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
A1. 编写程序,计算并输出下面数列前n项的和 (设n=15,结果取4位小数)。 数列为: 2/1,3/2,5/3,8/5,13/8,21/13,(结果:24.5701)main: Dim a, b, t, I As Integer Dim sum, q As Single a = 1 : b = 2 : sum = 0 For I = 1 To 15 q = b / a sum = sum + q t = a a = b b = b + t Next I sum = Format(sum, #.0000) MsgBox(Str(sum)A2. 编写程序,计算并输出所有六位正整数中同时能被3和7整除的数的个数及它们的平方根的和。(结果:个数:42858 平方根和:30742714.4533428)Main:Dim n, I As Integer Dim s As Double n = 0 : s = 0 For I = 100000 To 999999 If I Mod 3 = 0 And I Mod 7 = 0 Then n = n + 1 s = s + Math.Sqrt(I) End If Next I MsgBox(个数是 + Str(n) + Chr(10) + 平方根之和是 + Str(s)A3. 编写程序,计算并输出所有6位正整数中能被6整除且其十位数不是4的数之和,并求它们中的最大数。 (结果:和:7.42508E+10 最大值:999996)Main: Dim I, max As Long Dim s As Single max = 100000 For I = 100000 To 999999 If (I Mod 6) = 0 And (I Mod 100) 10) 4 Then s = s + I If (max eps) And (I 100) I = I + 1 迭代次数统计 x1 = x2 将上次计算结果作为本次计算的初值 x2 = 2.5 - Math.Log(x1) End While If I eps) And (I 100) I = I + 1 迭代次数统计 x1 = x2 将上次计算结果作为本次计算的初值 x2 = 2.5 + Math.Log(x1) End While If I 100 Then MsgBox(函数根: + Str(x2) + 迭代 + Str(I) + 次) Else MsgBox(已迭代了100次,没有达到精度要求!) End If End SubA12 编写程序,计算并输出下面级数前n项(n=49)中奇数项的和。 s = 1*2+2*3+3*4+4*5+n*(n+1)+(结果:21450)Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim n as integer, s as doubles = 0For n = 1 To 49 Step 2 s = s + n * (n + 1)Next nMsgbox(前50项中偶数项和S=&s)End SubA13编写程序,计算并输出所有5位正整数中能被7整除且其十位数不是7的数之和,并求它们中的最大数。 (和:6.364356E+08 最大值:99995)Dim I, max As Long Dim s As Single s = 0 max = 10000 For I = 10000 To 99999 If (I Mod 7 = 0) And (I Mod 100) 10 7) Then s = s + I If (max eps) And (Math.Abs(a - b) eps) If F(c) * F(b) 0 Then a = c If F(a) * F(c) eps) And (I 100) I = I + 1 x1 = x2 x2 = 2.5 (-x1) End While If I eps) And (I 100) I = I + 1 x1 = x2 x2 = 1.5 * Math.Sin(x1) End While If I eps) And (i 100) i = i + 1 迭代次数的统计 x1 = x2 将上次运算结果作为本次计算的初值 x2 = x1 - f(x1) / f1(x1) End While If i eps) And (Math.Abs(a - b) eps) If F(c) * F(b) 0 Then a = c If F(a) * F(c) 0 Then b = c c = (a + b) / 2 End While MsgBox(函数根为: + Str(c) + Chr(10) + 该点的函数值为 + Str(F(c) End SubA21 编写程序,统计10000到40000之间回文数的个数。(例:23732即为回文数,即正反读数据相同)(结果:300)Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i, j, p As Integer Dim a, b, c, d, f As Integer Dim str1 As String p = 0 str1 = For i = 10000 To 40000 a = i Mod 10 b = (i Mod 100) 10 c = (i Mod 1000) 100 d = (i Mod 10000) 1000 f = i 10000 j = a * 10000 + b * 1000 + c * 100 + d * 10 + f If i = j Then str1 = str1 + Str(i) + Space(3) p = p + 1 If p Mod 12 = 0 Then str1 = str1 + Chr(10) + Chr(13) End If Next MsgBox(p) End SubA22 编写程序,求5664,144的最大公约数(48)Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim num1 As Integer Dim num2 As Integer Dim inlarge As Integer Dim insmall As Integer Dim inrem As Integer num1 = 5664 num2 = 148 If num1 num2 Then inlarge = num2 insmall = num1 Else inlarge = num1 insmall = num2 End If inrem = inlarge Mod insmall While inrem 0 inlarge = insmall insmall = inrem inrem = inlarge Mod insmall End While Label6.Text = Label3.Text + 和 + Label5.Text + 的最大公约数为: Label7.Text = Str(insmall) End SubA23从三位奇数中找出其值恰好等于该数每位数字立方和的各个数之和。(结果:931)Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i, m, n, k As Integer Dim s As integer s = 0 For i = 101 To 999 Step 2 m = i 100 n = (i Mod 100) 10 k = i Mod 10 If (i = m * m * m + n * n * n + k * k * k) Then s = s + i End If Next MsgBox(str(s)End SubA24从三位偶数中找出其值恰好等于该数每位数字立方和的各个数之积。(结果:370)Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i, m, n, k As Integer Dim s As integer s = 1 For i = 100 To 998 Step 2 m = i 100 n = (i Mod 100) 10 k = i Mod 10 If (i = m * m * m + n * n * n + k * k * k) Then s = s * i End If Next MsgBox(str(s)End SubA25 编写程序,用牛顿切线法求方程f(x)=2x3-8x2+15=0(其中表示幂运算),在区间(0,3)上的近似实根r,迭代初值取1,精确到0.0001。提示:牛顿切线法的计算公式为x=x-f(x)/f(x)。(结果:1.88159488)Function f(ByVal x#) As Double f = 2 * x * x * x - 8 * x * x + 15 End Function Function f1(ByVal x#) As Double f1 = 6 * x * x - 16 * x End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x1, x2, eps As Double Dim i As Integer i = 1 x1 = 1 eps = 0.0001 x2 = x1 - f(x1) / f1(x1) While (Math.Abs(x1 - x2) eps) And (i 100) i = i + 1 x1 = x2 x2 = x1 - f(x1) / f1(x1) End While If i eps) And (i 100) i = i + 1 x1 = x2 x2 = x1 - f(x1) / f1(x1) End While If i eps) And (i 100) i = i + 1 x1 = x2 x2 = f(x1) End While If i eps) And (i 100)i = i + 1 x1 = x2 x2 = x1 - f(x1) / f1(x1) End While If i 100 Then MsgBox(函数根为: + Str(x2) Else MsgBox(已迭代了100次,没有达到精度要求!) End If End SubA30 编写程序,用牛顿切线法求方程f(x)=x3+4x2-10=0(其中表示幂运算),在区间(0,5)上的近似实根r,迭代初值1,精确到0.0001。提示:牛顿切线法的计算公式为x=x-f(x)/f(x)。 (1.36523)Function f(ByVal x As Double) As Double f = x 3
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 17年护考试题及答案解析
- 医学院教学质量评估检查制度
- 华北电力大学锅炉原理教案第 26 讲液两相流动参数与阻力、简单回路的水循环计算
- 华北电力大学锅炉原理教案第 4 讲 煤的发热量、结渣、积灰特性
- 华北电力大学工程热力学教案第19讲 气体与蒸汽的流动
- 一年级语文上册3数字1数字歌第1课时教案北师大版
- 四年级科学上册3生命在于运动教案1冀教版
- 2024秋七年级历史上册第三单元秦汉时期:统一多民族国家的建立和巩固第9课秦统一中国学案新人教版
- 边疆小说《啊,拓荒者!》 的矛盾解析分析研究 汉语言文学专业
- 基于错误集合的优化算法设计-洞察阐释
- 天津市河道管理条例
- CB/T 3177-1994船舶钢焊缝射线照相和超声波检查规则
- 国家开放大学《传感器与测试技术》实验参考答案
- 【广东】高层档案馆建筑方案文本2020
- 流行病学传染病流行病学幻灯片
- 药物配伍禁忌查询表
- 参加培训人员汇总表
- 0720小罐茶品牌介绍
- 手术记录-颈胸椎前后路脱位c7t
- PPT模板:小学生防溺水安全教育主题班会08课件(45页PPT)
- 如何当好副职
评论
0/150
提交评论