分享
分销 收藏 举报 申诉 / 8
播放页_导航下方通栏广告

类型历年vb题目整理(带答案).doc

  • 上传人:仙人****88
  • 文档编号:11723646
  • 上传时间:2025-08-09
  • 格式:DOC
  • 页数:8
  • 大小:86KB
  • 下载积分:10 金币
  • 播放页_非在线预览资源立即下载上方广告
    配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    历年 vb 题目 整理 答案
    资源描述:
    <p>1、算法描述:求的1~100之间所有偶数的和 &#39;注:请不要更改原程序结构,删除(1)、(2)、(3),并在对应位置填写正确的代码 &#39;Function func() &nbsp; (1) i As Integer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dim &nbsp; func = (2) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp;For i = 2 To 100 Step (3) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;func = func + i &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Next i End Function 2、操作要求: 顺序查找单词“name” : 输入10个不同的单词给数组,查找单词“name”是否在数组中;如果在,输出单词在数组中的位置,否则,输出“不在数组中”。 Sub main() &nbsp;Dim i As Integer &nbsp;Dim buzai As Boolean &nbsp;&#39;定义数组d,下界为1,上界为10,数据类型为string,在dim后完善语句 &nbsp; Dim &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(1) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;d(1 To 10) As String &nbsp; &nbsp; &#39;输入10个单词,在for语句后完善i的初始值与终值 &nbsp; &nbsp; For i =(2) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; to &nbsp; 10 &nbsp; &nbsp;&#39;输入每个单词给数组元素,在赋值号左侧添加变量 &nbsp; &nbsp; &nbsp;(3) = InputBox(&quot;Please input word &nbsp;&quot; &amp; i) &nbsp; &nbsp; &nbsp; &nbsp;d(i) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Next i &nbsp;buzai = True &nbsp;i = 0 &nbsp;While buzai = True And i &lt; 10 &nbsp; &nbsp;&#39;顺序查找单词,数组下标增1,在赋值号右侧添加表达式 i =(4) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;i+1 &#39;判断数组元素是否为单词&quot;name&quot;,在if语句后添加判断条件 &nbsp; &nbsp;If &nbsp; &nbsp;(5) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;d(i) = &quot;name&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;buzai = False &nbsp; &nbsp;End If &nbsp;Wend &nbsp; &nbsp;If buzai = False Then &nbsp; &nbsp; &nbsp;MsgBox &quot;在数组中的位置为:&quot; + Str(i) &nbsp; &nbsp;Else &nbsp; &nbsp; &nbsp;MsgBox &quot;不在数组中&quot; &nbsp; &nbsp;End If End Sub 3、小王今年26岁,资助了一名贫困大学生, &#39;他想从明年开始每年比上一年多资助一名贫困大学生。 &#39;编程求解小王到多少岁,就能资助到n名甚至更多大学生? Function func(n) &nbsp; &nbsp;stu = 1 &nbsp; &nbsp;age = 26 &#39;请完善下面两条语句 &nbsp; &nbsp;Do While stu &lt; Val(n) &nbsp; &nbsp; &nbsp; &nbsp;age = age + (1) &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp; &nbsp;stu = (2) + age – 25 &nbsp; &nbsp; &nbsp; &nbsp; stu &nbsp; &nbsp;Loop &nbsp; &nbsp;func = age End Function Sub Main() &nbsp; &nbsp;If Command = &quot;assess&quot; Then &nbsp; &nbsp; &nbsp; &nbsp;Open &quot;in.txt&quot; For Input As #1 &nbsp; &nbsp; &nbsp; &nbsp;Line Input #1, n &nbsp; &nbsp; &nbsp; &nbsp;Close #1 &nbsp; &nbsp; &nbsp; &nbsp;Open &quot;out.txt&quot; For Output As #1 &nbsp; &nbsp; &nbsp; &nbsp;Print #1, func(n) &nbsp; &nbsp; &nbsp; &nbsp;Close #1 &nbsp; &nbsp;Else &#39;请完善大学生数n的输入语句 &nbsp; &nbsp; &nbsp; &nbsp;(3) = InputBox(&quot;请输入大学生数 n:&quot;, &quot;Input&quot;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MsgBox func(n) &nbsp; &nbsp;End If End Sub 4、操作要求: 设计一个VB学习指导程序的窗口运行界面,界面设计如下图。要求 (1)打开“C:\MyExam\工程1.vbp”,设置窗体Form1属性值: 将该窗体标题命名为“VB学习指导”; (2)添加一个标签控件Label1,并设置如下属性值: 该控件填充内容“VB学习指导”; 字体为隶书,字形为粗体,字号为三号,字体颜色为调色板中第5行第7列,并居中对齐; (3)对标签控件Label2(请输入口令:),设置如下属性值: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;根据字体大小自动调整; (4)添加一个文本框控件Text1,并设置如下属性值: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;文本框高度为650,宽度为2215; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;文本框内容为空; (5)添加一个命令按钮Option2,并设置如下属性值: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;将该按钮标题命名为“退出”; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;字体为黑体,字号为四号; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;按钮宽度1575,高度735; (5)保存并提交。 5、操作要求: 打开&quot;C:\MyExam\工程1.vbp”,补充完成程序。实现当从键盘上输入x的值后,求函数y的值(当x&lt;0时,y=|3x+1|;当x&gt;=0时,y=4x+1)。如:输入-2后,输出结果:5. Function func(x) If x &lt; 0 Then &nbsp; &nbsp; &nbsp;func = (1) &nbsp; &nbsp; &nbsp; &nbsp;abs(3*x+1) Else &nbsp; &nbsp; &nbsp;func = (2) &nbsp; &nbsp; &nbsp; &nbsp;4*x+1 End If End Function 6、操作要求: 打开“C:\MyExam\工程1.vbp”补充完成程序并保存!该程序的功能是:从键盘上输入两个数a和b,比较a和b的大小,并输出较小的数。 Function func(a, b) If (1) Then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a<strong func="a" else="" if="" then="" a="">b &nbsp;func = b &nbsp;Else &nbsp;func = &quot;两数相等&quot; &nbsp;End If End If End Function 7、操作要求: 输入a、b、c的值,判断一元二次方程 ax^2+bx+c=0是否有解,如果无解则输出“无解” ,如果两个解相同则输出“两解相同”,否则输出“两解不同”。 Function f(a, b, c) &#39;请完成其它的判断语句 &nbsp; &nbsp;If b * b - 4 * a * c &lt; 0 Then f = &quot;无解&quot; &nbsp; &nbsp;If b * b - 4 * a * c = 0 Then (1) &nbsp; &nbsp; &nbsp; &nbsp;f=&quot;两解相同&quot; &nbsp; &nbsp;(2) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If b * b - 4 * a * c &gt; 0 Then f = &quot;两解不同&quot; End Function Sub Main() &nbsp; &nbsp;If Command = &quot;assess&quot; Then &nbsp; &nbsp; &nbsp; &nbsp;Open &quot;in.txt&quot; For Input As #1 &nbsp; &nbsp; &nbsp; &nbsp;Line Input #1, a &nbsp; &nbsp; &nbsp; &nbsp;Line Input #1, b &nbsp; &nbsp; &nbsp; &nbsp;Line Input #1, c &nbsp; &nbsp; &nbsp; &nbsp;Close #1 &nbsp; &nbsp; &nbsp; &nbsp;Open &quot;out.txt&quot; For Output As #1 &nbsp; &nbsp; &nbsp; &nbsp;Print #1, f(a, b, c) &nbsp; &nbsp; &nbsp; &nbsp;Close #1 &nbsp; &nbsp;Else &nbsp; &nbsp; &nbsp; &nbsp;a = InputBox(&quot;请输入 a&quot;, &quot;Input&quot;) &nbsp; &nbsp; &nbsp; &nbsp;b = InputBox(&quot;请输入 b&quot;, &quot;Input&quot;) &#39;请完成变量c的输入语句 &nbsp; &nbsp; &nbsp; &nbsp;(3) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c = InputBox(&quot;请输入 c&quot;, &quot;Input&quot;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MsgBox f(a, b, c) &nbsp; &nbsp;End If End Sub 8、操作要求: 打开“C:\MyExam\工程1.vbp”补充完成程序并保存!该程序的功能是: 求实数x的绝对值。 Function func(x) &nbsp; &nbsp;If x &gt;= 0 &nbsp; (1) &nbsp; &nbsp; &nbsp; &nbsp;then &nbsp; &nbsp; &nbsp; &nbsp; func = x &nbsp; &nbsp;Else &nbsp; &nbsp; func = (2) &nbsp; &nbsp; &nbsp; &nbsp; -x &nbsp; &nbsp;(3) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if End Function 9、操作要求: 打开“C:\MyExam\工程1.vbp”进行以下操作后并保存!填空完成程序,计算N!的值并在窗体上打印出结果,如输入:3,则输出:6。(注:N!=1×2×…×N) Function func(n) Dim i As Integer (1) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;func=1 For i = 1 To (2) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;n func = func * i &nbsp;&#39;计算N! Next i End Function 10、操作题:“提示信息”界面设计,如下图所示,要求 (1)打开“C:\MyExam\工程1.Vbp”,对窗体Form1设置如下属性值: 窗体标题为“提示信息”; 背景色为调色板第1行第7列。 (2)添加一个标签控件Label,并设置如下属性值: 标签标题为“要继续吗?”(注:“?”为中文标点符号); 标签高度为495,宽度为1935; 字体为楷体_GB2312,字形为常规,字号为三号,字体颜色为调色板第5行第8列,背景类型为0。 (3)添加一个按钮控件CommandButton,并设置如下属性值: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;按钮标题为“否”;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;字号为小四。 (4)保存并提交。 11、操作要求: 输入10位同学的英语成绩存放在数组score中,利用选择排序算法按照从大到小的顺序进行排序 。 &#39; 算法描述: &#39;输入10位同学的英语成绩存放在数组score中 &#39;利用选择排序算法按照从大到小的顺序进行排序 &#39;定义数组score,下界为1,上界为10,数据类型为Single &nbsp; Dim &nbsp;(1) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;score(1 To 10) As Single Function f() &nbsp; &nbsp;&#39;i为排序的次数,应该排序9次,为i添加初值和终值 &nbsp; &nbsp;For i =(2) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 To 9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Min = score(i): &nbsp; &nbsp; &nbsp; &nbsp; m = i &nbsp; &nbsp; &#39;j为每次排序的数的范围,应从i+1开始直到第10个数,为j添加初值和终值 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;For j =(3) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i + 1 To 10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If score(j) &gt; Min Then Min = score(j): &nbsp; &nbsp; &nbsp; m = j &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Next j &nbsp; &nbsp; &nbsp; &nbsp;&#39;以k为中间变量,编写交换score(i)和score(m)的语句 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;k = score(i) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;score(i) = score(m) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(4) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; score(m) = k &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Next i &nbsp; st = &quot;排序后的数列为:&quot; &nbsp; &nbsp; For i = 1 To 10 &nbsp; &nbsp; &nbsp; &nbsp;st = st + Str(score(i)) + &quot; &nbsp; &quot; &nbsp; &nbsp; Next i &nbsp; &nbsp; &nbsp; &nbsp;f = st End Function Sub Main() &nbsp; Dim i As Integer, m As Integer, k As Integer, j As Integer &nbsp; Dim st As String &nbsp; &nbsp;If Command = &quot;assess&quot; Then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Open &quot;in.txt&quot; For Input As #1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dim x As String &nbsp; &nbsp; &nbsp; &nbsp;For i = 1 To 10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Line Input #1, x &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; score(i) = Val(x) &nbsp; &nbsp; &nbsp; &nbsp;Next i &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Close #1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Open &quot;out.txt&quot; For Output As #1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Print #1, f() &nbsp; &nbsp; &nbsp; &nbsp;Close #1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Else &nbsp; &nbsp; &nbsp; &nbsp;For i = 1 To 10 &nbsp; &nbsp; &nbsp; &#39;输入10位同学的英语成绩,在赋值号左侧添加变量 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(5) = InputBox(&quot;请输入第&quot; &amp; i &amp; &quot;个数据&quot;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; score(i) &nbsp; &nbsp; &nbsp; &nbsp;Next i &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MsgBox f() &nbsp; &nbsp;End If End Sub 12、购物问题:购物满1000元,打7折,800到1000元,打8折,500到800元,打9折。 &nbsp; &nbsp; &nbsp;Private &nbsp; sub &nbsp; command1_click() &nbsp; &nbsp; &nbsp; &nbsp; X=val(text1.text) &nbsp; &nbsp; &nbsp; &nbsp; If &nbsp; x&gt;=1000 &nbsp; &nbsp; then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(1) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Y=0.7*x &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Elseif &nbsp; &nbsp;(2) &nbsp; &nbsp;then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x&gt;=800 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Y=0.8*x &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Elseif &nbsp; &nbsp;x&gt;=500 &nbsp; &nbsp; &nbsp;then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(3) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Y=0.9*x &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Y=x &nbsp; &nbsp; &nbsp; End &nbsp;if &nbsp; &nbsp; &nbsp; Text2.text=y &nbsp; &nbsp; &nbsp;End &nbsp; sub 13、十进制转化成二进制问题:将一个十进制数转化为二进制数。 &nbsp;Function &nbsp;func(x) Dim &nbsp; bin(32),j,str Str=”” j=0 do &nbsp; while &nbsp;(x&gt;0) bin(j)=(1) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x &nbsp;mod &nbsp;2 (2) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x=x\2 j=j+1 loop do &nbsp;while (j&lt;&gt;0) str=str&amp;bin(j-1) j=(3) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j-1 loop func=str end &nbsp;function 14、水仙花数问题:水仙花数是满足下面条件的一组三位的正整数,它们满足条件:每一位上数字的立方之和恰好等于它自己。例如:153就是一个水仙花数,13+53+33=153,请找出所有的水仙花数及个数。 参考程序代码如下: 方法一: Private Sub Command1_Click() &nbsp; &nbsp;Dim sum As Integer &nbsp; &nbsp;Dim i, a, b, c As Integer &nbsp; &nbsp;List1.Clear &nbsp; &nbsp;Sum=0 &nbsp; &nbsp;For i = 100 To 999 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a = i \ 100 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‘求得百位上的数字 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b = i \ 10 Mod 10 &nbsp; &nbsp; &nbsp; &nbsp;‘求得十位上的数字 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c = i Mod 10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‘求得个位上的数字 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If a ^ 3 + b ^ 3 + c ^ 3 = i Then &nbsp; ‘判断是否满足条件 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;List1.AddItem (Str(i)) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sum = sum + 1 &nbsp; &nbsp; ‘统计个数 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End If &nbsp; &nbsp;Next i &nbsp; &nbsp;Label1.Caption = &quot;个数:&quot; + Str(sum) End Sub 方法二: Private Sub Command1_Click() &nbsp; &nbsp;Dim sum As Integer &nbsp; &nbsp;Dim i, j, k As Integer &nbsp; &nbsp;List1.Clear &nbsp; &nbsp;Sum=0 &nbsp; &nbsp;For i = 1 To 9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘百位数 &nbsp; &nbsp; &nbsp; &nbsp;For j = 0 To 9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘十位数 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;For k = 0 To 9 &nbsp; &nbsp; &nbsp; &nbsp; ‘个位数 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If &nbsp;i ^ 3 + j ^ 3 + k ^ 3 = 100 * i + 10 * j + k Then &nbsp;‘是否满足条件 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;List1.AddItem (Str(100 * i + 10 * j + k)) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sum = sum + 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‘统计个数 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Next k &nbsp; &nbsp; &nbsp; &nbsp;Next j &nbsp; &nbsp;Next i &nbsp; &nbsp;Label1.Caption = &quot;个数:&quot; + Str(sum) End Sub 15、用递归算法来计算斐波那契数列1,1,2,3,5,8,13,21……的第N项,我们可以写出这样的计算公式: &nbsp;fib(n)=fib(n-1)+fib(n-2) &nbsp;(n&gt;2) &nbsp; fib(2)=1 &nbsp; &nbsp; (n=2) fib(1)=2 &nbsp; &nbsp; (n=1) Fib函数参考程序代码如下: Function fib(n As Integer) As Long &nbsp;‘计算斐波那契数列第n项 &nbsp; &nbsp;If n = 1 or n=2 Then &nbsp; &nbsp; &nbsp; &nbsp; fib = 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‘已知第1项、第2项均为1 &nbsp; &nbsp;Else &nbsp; &nbsp; &nbsp; fib = fib(n-1)+fib(n -2) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‘计算公式,fib(n)=fib(n-1)+fib(n-2) &nbsp; &nbsp;End If &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‘要求fib(n-1)和fib(n-2)需要再次执行算法fib End Function 也可以用如下代码来完成: Function fib(n As Integer) As Long &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‘计算斐波那契数列第n项 &nbsp; &nbsp;If n = 1 or n=2 Then &nbsp;fib = 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘已知第1项、第2项均为1 &nbsp; &nbsp;If &nbsp;n&gt;2 then &nbsp;fib = fib(n-1)+fib(n -2) &nbsp; &nbsp;‘计算公式 End Function 参考程序代码如下: Private Sub Command1_Click() &nbsp; &nbsp;Dim n As Integer &nbsp; &nbsp;Dim an As Long &nbsp; &nbsp;n = Val(Text1.Text) &nbsp; &nbsp;an = fib(n) &nbsp; &nbsp;Text2.Text = Str(an) End Sub</strong></p><!--0时,y=|3x+1|;当x-->
    展开阅读全文
    提示  咨信网温馨提示:
    1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
    2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
    3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
    4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
    5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
    6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

    开通VIP折扣优惠下载文档

    自信AI创作助手
    关于本文
    本文标题:历年vb题目整理(带答案).doc
    链接地址:https://www.zixin.com.cn/doc/11723646.html
    页脚通栏广告

    Copyright ©2010-2025   All Rights Reserved  宁波自信网络信息技术有限公司 版权所有   |  客服电话:0574-28810668    微信客服:咨信网客服    投诉电话:18658249818   

    违法和不良信息举报邮箱:help@zixin.com.cn    文档合作和网站合作邮箱:fuwu@zixin.com.cn    意见反馈和侵权处理邮箱:1219186828@qq.com   | 证照中心

    12321jubao.png12321网络举报中心 电话:010-12321  jubao.png中国互联网举报中心 电话:12377   gongan.png浙公网安备33021202000488号  icp.png浙ICP备2021020529号-1 浙B2-20240490   


    关注我们 :微信公众号  抖音  微博  LOFTER               

    自信网络  |  ZixinNetwork