1、杭州商学院VB上机考试全代码Private Sub Form_Click()【131】-【程序设计】-题目:(事件)单击窗体。 (响应)已知S=1+1/4+1/9+1/16+1/25+1/100, 结果输出在窗体上。-将结果存入变量S中-Dim s As Single* Program *Dim i As Integers = 0For i = 1 To 10s = s + 1 / (i 2)NextPrint s* End *YZJ (s)End SubPrivate Sub YZJ(i As Single) Dim OUT As Integer OUT = FreeFile Open Ap
2、p.Path & 3.out For Output As #OUT Print #OUT, i Close #OUTEnd SubPrivate Sub Form_Click()【132】-【程序设计】-题目:(事件)单击窗体。 (响应)在窗体上打印数列2/1,3/2,5/3,8/5,13/8 的前10项,并求其和。-注意:请在指定的事件内编写代码。-Dim s As Single* Program *Dim i, j, k, m As Integers = 0i = 2j = 1For k = 1 To 10m = jPrint (i) & / & (j)s = s + i / jj = i
3、i = i + mNext* End *YZJ (s)End SubPrivate Sub YZJ(i As Single) Dim OUT As Integer OUT = FreeFile Open App.Path & 4.out For Output As #OUT Print #OUT, i Close #OUT End SubPrivate Sub Form_Click()【133】-【程序设计】-题目:(事件)单击窗体。 (响应)一球从100米高度自由落下,每次落地返回 原高度的一半,求第10次落地时,共经过多 少米?并将结果在窗体上输出。-注意:请在指定的事件内编写代码。-Di
4、m s As Single* Program *Dim j, i As Integers = 0j = 100For i = 2 To 10j = j / 2s = s + 2 * jNexts = 100 + sPrint s* End *YZJ (s)End SubPrivate Sub YZJ(i As Single) Dim OUT As Integer OUT = FreeFile Open App.Path & 5.out For Output As #OUT Print #OUT, i Close #OUT End SubPrivate Sub Form_Click()【137】
5、-【程序设计】-题目:(事件)双击窗体。 (响应)把一元钞票换成一分、二分和五分的硬币 (每种至少有一枚),求出其所有的换法, 把结果输出在窗体上。 将所有的换法的数目存入变量N中-注意:请在指定的事件内编写代码。-Dim n As Integern = 0* Program *Dim i, j, k As IntegerFor i = 1 To 100For j = 1 To 50For k = 1 To 20If (i + 2 * j + 5 * k) = 100) ThenPrint iPrint jPrint kn = n + 1End IfNextNextNext* End *YZJ
6、 (n)End SubPrivate Sub YZJ(i As Integer) Dim OUT As Integer OUT = FreeFile Open App.Path & 9.out For Output As #OUT Print #OUT, i Close #OUT End SubPrivate Sub Form_Click()【142】-【程序设计】-题目:(事件)单击窗体。 (响应)编写程序求101112+111213+151617的结果, 并将结果输出到窗体上。 将结果存入变量M中-注意:请在指定的事件内编写代码。-Dim m As Long* Program *Dim i
7、, j As IntegerDim s As LongFor i = 10 To 15s = 1For j = i To i + 2s = s * jNextm = m + sNextPrint m* End *YZJ (m)End SubPrivate Sub YZJ(i As Long) Dim OUT As Integer OUT = FreeFile Open App.Path & 14.out For Output As #OUT Print #OUT, i Close #OUT End SubPrivate Sub Form_Click()【144】-【程序设计】-题目:(事件)单
8、击窗体。 (响应)在窗体上输出100200之间的所有合数。 求出所有数之和存入SUM中-注意:请在指定的事件内编写代码。-Dim sum As Integersum = 0* Program *Dim i, j, s As IntegerFor i = 100 To 200For j = 2 To Sqr(i)If (i Mod j) = 0 ThenPrint isum = sum + iExit ForEnd IfNextNextPrint sum* End *YZJ (sum)End SubPrivate Sub YZJ(i As Integer) Dim OUT As Integer
9、OUT = FreeFile Open App.Path & 16.out For Output As #OUT Print #OUT, i Close #OUT End SubPrivate Sub Form_Click()【145】-【程序设计】-题目:(事件)双击窗体。 (响应)求出100200之间,能被5整除,但不能被3整除的数。 并求所有数之和,存入变量中SUM中-注意:请在指定的事件内编写代码。-Dim sum As Integersum = 0* Program *Dim sum As Integersum = 0* Program *Dim i As IntegerFor i = 100 To 200If (i Mod 5) = 0 And (i Mod 3) 0) ThenPrint isum = sum + iEnd IfNext*
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1