当前位置:编程学习 > VB >>

求VB数据中的一维至二维习题?

难度不要太大....初学者来的我....
最好附上参考答案
答案:vb编程题:求数组中的最小数及其位置还有冒泡排序,选择排序。 http://www.docin.com/p-526792.html这个网站也不错下面是我学vb是数组的练习题答案,你看看也许会有帮助8.1Option Base 1Dim a(10) As IntegerDim s, k As IntegerPrivate Sub Form_click()For i = 1 To 10a(i) = InputBox("请输入一组数")Print a(i);Next iFor k = 1 To 5s = a(k)a(k) = a(11 - k)a(11 - k) = sNext kPrintFor i = 1 To 10Print a(i);Next iEnd Sub8.2Option Base 1Dim a As Variant, b As VariantPrivate Sub Form_click()a = Array(2, 8, 7, 6, 4, 28, 70, 25)b = Array(79, 27, 32, 41, 57, 66, 78, 80)For i = 1 To 8Print a(i) + b(i);Next iEnd Sub8.7Dim a(1 To 10, 1 To 10) As IntegerPrivate Sub Form_click()For i = 1 To 10   For j = 1 To 10   If i = j Then   a(i, j) = 1   ElseIf i + j = 11 Then   a(i, j) = 1   Else  a(i, j) = 0   End If   Print a(i, j);Next jPrintNext iEnd Sub8.5Private Sub Form_Click()Dim N As IntegerN = InputBox("请输入人数")ReDim A(1 To N, 1 To 5)For I = 1 To N  Print  For J = 1 To 5   Select Case J    Case 1       MS$ = "请输入姓名"    Case 2    MS$ = "请输入性别"        Case 3        MS$ = "请输入年龄"    Case 4    MS$ = "请输入文化程度"    Case 5    MS$ = "请输入籍贯"   End Select     A(I, J) = InputBox(MS$, "数据输入")    Print Tab(J * 10); A(I, J); Next J, I PrintPrint "检索名册"DoMS$ = InputBox("请输入检索的姓名", "检索名册") I = 1  While MS$ <> A(I, 1) And I < N    I = I + 1  Wend  If I >= N Then    Print "查无此人"  Else   For J = 1 To 5   Print Tab(J * 10); A(I, J);   Next J   Print  End If ANS = MsgBox("是否继续检索", 4, "继续查询") Loop Until ANS = 7End Sub8.8Option Base 1Dim a(), b(), m As Integer, n As IntegerPrivate Sub Form_Click()n = InputBox("请输入行数")m = InputBox("请输入列数")ReDim a(n, m), b(m, n)For i = 1 To n  For j = 1 To m     a(i, j) = Int(Rnd * 100)     Print a(i, j);  Next j  PrintNext i冒泡排序Private Sub Form_Click()Static x(1 To 10) As Integera = "请输入一组数:"For i = 1 To 10x(i) = InputBox(a)Next iFor i = 10 To 2 Step -1For j = 1 To i - 1If x(j) > x(j + 1) Then  '此式大于号可以改为小于t = x(j + 1)x(j + 1) = x(j)x(j) = tEnd IfNext jNext iFor i = 1 To 10Print x(i)Next iEnd Sub选择排序Private Sub Form_Click()Dim a(4) As DoubleDim n As DoubleDim i, j, k, tFor i = 0 To 4a(i) = InputBox("请输入:", "选择法排序")Next iFor i = 0 To 3k = iFor j = i + 1 To 4If a(k) > a(j) Then k = jNext jIf k <> i Then t = a(k): a(k) = a(i): a(i) = tNext iFor i = 0 To 4Print a(i)Next iEnd Sub8.6Dim a()Private Sub Form_Click()ReDim a(1 To 10, 1 To 2)a(1, 1) = "207号": a(1, 2) = 14.5a(2, 1) = "077号": a(2, 2) = 15.1a(3, 1) = "156号": a(3, 2) = 14.2a(4, 1) = "231号": a(4, 2) = 14.7a(5, 1) = "453号": a(5, 2) = 15.2a(6, 1) = "276号": a(6, 2) = 13.9a(7, 1) = "096号": a(7, 2) = 15.7a(8, 1) = "122号": a(8, 2) = 13.7a(9, 1) = "339号": a(9, 2) = 14.9a(10, 1) = "302号": a(10, 2) = 14.5Print Tab(2); "名次"; Tab(12); "运动员号"; Tab(23); "成绩"For M = 10 To 2 Step -1  For I = 1 To M - 1   If a(I, 2) > a(I + 1, 2) Then      MM = a(I, 2): a(I, 2) = a(I + 1, 2): a(I + 1, 2) = MM      NN = a(I, 1): a(I, 1) = a(I + 1, 1): a(I + 1, 1) = NN    End IfNext I, MFor I = 1 To 10    Print Tab(2); I;    For J = 1 To 2      Print Tab(J * 8 + 6); a(I, J);    Next J    PrintNext IEnd Sub
1.AB之垂直距离为何?
a.19.5606 b. 19.6506 c. 19.6605

ABC之角度为何?
a. 51.589° b. 51.895° c. 51.985°

3. 红色剖面线区之面积为何?
a. 108.5891 b. 108.8519 c. 108.9815

4. 绿色剖面线区之周长为何?
a. 100.4537 b. 100.5374 c. 100.7354

这是 明经CAD社区 那里批发来,没什么意义

上一个:怎么备战将要来到的二级VB考试?
下一个:关于VB,帮我写段代码

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,