1、已知x,y,z 3个变量中存放了3个不同的数,比较它们的大小并进行调整,使得x x = InputBox(\y = InputBox(\z = InputBox(\ Print Tab(8); \ y\ z\Print \排序前:\ \ \If x < y Then t = x: x = y: y = t: If x < z Then t = x: x = z: z = t: If y < z Then t = y: y = z: z = t: Print \排序后:\ \ \End Sub 2.0到200 被5 或11 整除的数的和 Private Sub Command1_Click() Dim i% For i = 0 To 200 If i Mod 11 = 0 Ori Mod 5 = 0 Then Sum = Sum + i End If Next i Print \总和是\End Sub 3、从键盘输入三角形的三条边a,b,c的值,根据其数值,判断能形。 Private Sub Command1_Click() Dim a%, b%, c% a = Val(InputBox(\b = Val(InputBox(\c = Val(InputBox(\ If a + b > c And b + c > a And a + c > b Then MsgBox (\能构成三角形\Else MsgBox (\不能构成三角形\End If End Sub 4、随机产生10个[30,100]内的整数,求最小值及所对应的下标。 Private Sub Form_click() Dim a(1 To 10) As Integer, zb%, mina%, i% For i = 1 To 10 a(i) = Int(Rnd * 71 + 30) Print a(i); Next i zb = 1 mina = a(1) For i = 2 To 10 If mina >a(i) Then mina = a(i): zb = i Next i Print Print \下标=\End Sub 5、随机产生10个[30,100]内的整数,求最大值、最小值和平均值。 Dim a(1 To 10) As Integer, amin, amax, i%, avera! Private Sub Form_Click() For i = 1 To 10 a(i) = Int(Rnd * 71 + 30) Next i amin = a(1) amax = a(1) avera = a(1) For i = 2 To 10 If a(i) >amax Then amax = a(i) If a(i) For i = 1 To 10 Print a(i); Next i Print Print \End Sub 6、随机产生10个[30,100]内的整数,求最大值及所对应的下标 Private Sub Form_Click() Dim a(9), max%, imax% For i = 0 To 9 a(i) = Int(Rnd * 71 + 30) Print a(i); Next i Print max = a(0) For i = 1 To 9 If max Next i Print \Print \下标=\End Sub 7、某次歌曲大奖赛,有7个评委。如果分别输入7个评委对某个参赛者的打分数,按照去掉一个最高分和一个最低分的计算办法,求出该参赛者的平均得分。 Private Sub Command1_Click() Dim mark!, max!, min!, aver!, i% aver = 0 For i = 1 To 7 mark = InputBox(\输入第\位评委的打分\If i = 1 Then max = mark: min = mark Else If mark < min Then min = mark If mark > max Then max = mark End If aver = aver + mark Next i aver = (aver - min - max) / 5 Print aver End Sub 8,9、求s=a+aa+aaa+...aaaaa(n个a),其中a和n的值随机产生,a的范围是[1,9]的整数,n的范围是[5,10]。 如a=3,n=6,则s=3+33+333+3333+33333+333333。编程确定n和a的值,并计算s。 Private Sub Form_click() Dim s!, t!, i!, a%, n% a = Int(Rnd * 9 + 1) n = Int(Rnd * 6 + 5) t = 0: s = 0 Print Tab(9); \Print For i = 1 To n t = t * 10 + a s = s + t Print Tab(9); t Next i Print Print Tab(9); \End Sub 10.产生1-100以内的素数 Private Sub Command1_Click() Dim i%, j%, tag As Boolean For j = 1 To 100 tag = True For i = 2 To j - 1 If j Mod i = 0 Then tag = False Next i If tag Then Print j; Next j End Sub 11、计算100~300之间所有能被3和7整除的数之和。 Private Sub Command1_Click() Dim s%, i% s = 0 For i = 100 To 300 If i Mod 3 = 0 Ori Mod 7 = 0 Then s = s + i End If Next i Print \End Sub 12.输入一年份,判断他是否为闰年,并现实是否是闰年的有关信息。 Private Sub Command1_Click() Dim y% y = Val(Text1) If y Mod 4 = 0 And y Mod 100 <>0 Or y Mod 400 = 0 Then MsgBox (y & \年是闰年\Else MsgBox (y & \年是平年\End If End Sub 13、编程求200--400范围内5的倍数或7的倍数之和。(一个数如果同时是7和5的倍数,则只能加一次。) Private Sub Command1_Click() Dim s1%, s2%, s3%, i% s1 = 0 s2 = 0 For i = 200 To 400 If i Mod 5 = 0 Ori Mod 7 = 0 Then s1 = s1 + i End If Next i For i = 200 To 400 If i Mod 5 = 0 Andi Mod 7 = 0 Then s2 = s2 + i End If Next i s3 = s1 - s2 Print s3 End Sub 14.利用inputbox函数输入两个整数,求它们的最大公约数 Private Sub Command1_Click() n1 = InputBox(\输入n\ m1 = InputBox(\输入m\ If m1 > n1 Then m = m1: n = n1 Else m = n1: n = m1 End If r = m Mod n Do While r <> 0 m = n n = r r = m Mod n Loop Print \的最大公约数是:\End Sub 15、随机产生一个三位正整数,然后逆序输出,产生的数与逆序数同时显示。例如,产生246,输出是642。 Private Sub Command1_Click() Text1 = Int(Rnd * 900 + 100) End Sub Private Sub Command2_Click() Dim x%, x1%, x2%, x3% x = Val(Text1) x1 = x Mod 10 x2 = (x Mod 100) \\ 10 x3 = x \\ 100 Text2 = x1 * 100 + x2 * 10 + x3 End Sub