1、输入“ASDFGT”,显示“TGFDSA”19. 随机产生10个30,100内的整数,求最大值及所对应的下标20. 随机产生10个30,100内的整数,求最大值、最小值和平均值。21. 随机产生10个30,100内的整数,求最小值及所对应的下标。22. 随机生成一个整型的二维数组,范围在10,20之间,以下三角形式输出该数组。23. 随机产生10个1100的正整数放入数组,显示产生的数,求最大值、最小值、平均值。24. 利用随机函数生成一个44的矩阵(即二维矩阵),范围是20,50内的整数,输出该矩阵所有数据之和25. 已知有序数组a(),编程插入x(x的值为14)。数组a中的元素分别为12,
2、6,4,89,75,63,100,20,31。26. 编写一函数,计算Double类型一维数组所有元素的平均值。27. 用函数过程求表达式1+1/2+1/3+1/4+1/n的和.28. 编一子过程ProcMin,求一维数组a中的最小值,子过程的形参自己确定。29. 编一个函数,求一维数组a中的最大值,函数的形参自己确定。30. 编写一个过程计算并输出区间100,1000内所有素数的和(要求判断素数使用过程(函数或子过程)来实现。调用该过程。(提示:只能被1和自身整除的自然数称为素数。)(注:本答案第一行代码应在题目之后,自行调整)Private Sub Command11_Click()Dim
3、 max% X1 = Val(InputBox(input)X2 = Val(InputBox(x3 = Val(InputBox(max = X1If max = X2 Thenmax = X2End If= x3 Thenmax = x3MsgBox (3个数之中的最大数max= & max)End SubPrivate Sub Command12_Click()2. 有一元二次方程:a = Val(InputBox(B = Val(InputBox(c = Val(InputBox(s = B 2 - 4 * a * cIf a 0 ThenIf s = 0 Then两个相等实根Else
4、If s 两个不相等实根ElseIf s = 60 ThenPrivate Sub Command14_Click()yes = Val(InputBox(yearIf yes Mod 4 = 0 And yes Mod 100 = 90 MsgBox (优秀 Case Is = 80良好= 70中= 60及格 Case Else不及格 End Select Private Sub Command16_Click()a = 645n = Len(a)For i = 1 To Int(n / 2)c = Mid(a, i, 1)Mid(a, i, 1) = Mid(a, n - i + 1, 1
5、)Mid(a, n - i + 1, 1) = cNext iMsgBox (a)Private Sub Command1_Click()7. 输入两个整数,求它们的最大公约数m = Val(InputBox(input m值n = Val(InputBox(input n值If n m Thent = nn = mm = tr = m Mod nDo While r min = Xsum = sum + XAvg = (sum - max - min) / 5最高分=最低分= min)总和=平均分= Avg)Private Sub Command10_Click()Dim ch As Str
6、ingch = ASDEASn = 0For i = 1 To Len(ch)st = Mid(ch, i, 1)If UCase(st) = A Then字符串中出现A字符的系数Private Sub Command6_Click()X = 13Do While X = max Thenmax = a(i)maxi = imax=maxi= maxi)Private Sub Command23_Click()Dim a(10) As Integer, max%, min%min = a(0)min = a(i)sum = sum + a(i)min=avg= sum / 10)Private
7、 Sub Command17_Click()Dim a(10) As IntegerMini = 0If a(i) = min ThenMini = imini= Mini)Private Sub Command18_Click()Dim a(10, 10) As IntegerFor j = 0 To 9a(i, j) = Int(Rnd * 11 + 10)For j = 0 To iPrint a(i, j),PrintPrivate Sub Command19_Click()a(i) = Int(Rnd * 100 + 1)Print a(i)Private Sub Command24
8、_Click()Dim a(4, 4) As IntegerDim sum%, i%, j%For i = 0 To 3For j = 0 To 3a(i, j) = Int(Rnd * 31 + 20)sum = sum + a(i, j)Private Sub Command25_Click() Dim a(), iMin%, n%, i%, j%, t% a = Array(2, 6, 4, 89, 75, 63, 100, 20, 31) X = 14 n = UBound(a) 获得数组的下标上界 For i = 0 To n - 1 进行n-1轮比较 iMin = i 对第i轮比较
9、时,初始假定第i个元素最小 For j = i + 1 To n 在数组 i+1n个元素中选最小元素的下标 If a(j) a(iMin) Then iMin = j Next j t = a(i) i+1n个元素中选出的最小元素与第i个元素交换 a(i) = a(iMin) a(iMin) = t Next i For k = 0 To n 查找欲插入数x在数组中的位置 If X a(k) Then Exit For Next k ReDim Preserve a(n + 1) 数组增加一个元素 For i = n To k Step -1 数组元素后移一位,腾出位置 a(i + 1) =
10、a(i) a(k) = X For i = 0 To n + 1 Print a(i); NextPrivate Sub Command26_Click()Dim a(), n%, s! a = Array(1, 4, 7, 9, 12, 23, 56) n = UBound(a) s = sum1(a() s) s / n)Private Sub Command27_Click()n = InputBox(INPUTs = sum2(n)SUM2=Private Sub Command28_Click()28. 编一子过程ProcMin,求一维数组a中的最小值,子过程的形参自己确定Dim a(), n%, min% a = Array(1, 4, 7, 9, 12, -23, 56) Call procmin(a(), min)Private Sub Command29_Click() s = max(a()Private Sub Command30_Click()Dim i%, sum!, f%For i = 100 To 1000Call procs(i, f)If f = 1 Then
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1