VB二级期末考试VB二级实验考题课件.docx

上传人:太** 文档编号:86417557 上传时间:2023-04-14 格式:DOCX 页数:3 大小:12.43KB
返回 下载 相关 举报
VB二级期末考试VB二级实验考题课件.docx_第1页
第1页 / 共3页
VB二级期末考试VB二级实验考题课件.docx_第2页
第2页 / 共3页
点击查看更多>>
资源描述

《VB二级期末考试VB二级实验考题课件.docx》由会员分享,可在线阅读,更多相关《VB二级期末考试VB二级实验考题课件.docx(3页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、VB1 .求一个四位数的各位数字的立方和。Private Function fun(n As Integer) as longDim d as integer, I as integer, s as integerFor i = 1 to 4d = val ( mid (n,I,l)s = s+dA3Next iFun = sEnd function.求1到100之间的偶数之积。Private Function fun(m As Integer) as doubleDim y as double , i as integery= 1m=100For i =1 to mif i mod 2 =

2、0 Theny = y* 1End ifNextFun = yEnd function.计算n门课程的平均值,计算结果作为函数值返回。Private Function fun(a() As Integer,! as integer ) as doubleDim i as integer , y as singleFor i = 1 to ny = y + a(i)Nextfun = y / nEnd function.计算0到100范围内所有偶数的平方和。Private sub command l_click()d = fun ()Text 1.text = dSave DataEnd sub

3、Function fun()Sum = 0For i =0 to 100 step 2Sum = sum + i * INext I fun=sumEnd function2 .计算输出给定整数n的所有因子之和(不包括1马自身),规定n的值不大于1000。Private function fun (n as integer ) as integerDim s as integer , i as integerFor i = 2 to n -1If n mod i = 0 thenEnd ifNextfun = sEnd function.判断一个数是否是素数的函数primePrivate Fu

4、nction prime (n As Integer) As BooleanDim i As IntegerIf n =1 then exit functionFori = 2Ton-lIf n Mod i= 0 Then Exit ForNext iIf i = n Then Prime = TrueEnd Function.将字符串逆序的函数resersePrivate function reverse(n as string ) as stringDim i as integerFor i = 1 to len(n)Reverse = mid(n,I,l)&reverseNext iEn

5、d function.求两个数最大公约数的函数gedPrivate function gcd(m as integer, n as integer) as integerDim r as integerDo r = m mod nm = nn = rLoop while r 0ged = mEnd function3 .求n!的值的函数factPrivate Function fact (n as integer) As longDim i As Integerfact - 1For i = 1 To nfact = fact * iNext iEnd Function.求一维数组元素之和的过程。Private function total(a() as integer) as integerDim i as integerFor I = LBound(a) to UBound(a)Total = total + a(i)Next iEnd functon

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > 解决方案

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

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁