VB字符出现最多字符以及次数数统计_第1页
VB字符出现最多字符以及次数数统计_第2页
VB字符出现最多字符以及次数数统计_第3页
VB字符出现最多字符以及次数数统计_第4页
VB字符出现最多字符以及次数数统计_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、1,文本出现字符次数最多的字母,及出现的次数Dim a(1 To 26) As Integer Dim max As Integer n = Len(s) For i = 1 To n k = Asc(Mid$(s, i, 1) If (k >= 65 And k <= 90) Then a(k - 64) = a(k - 64) + 1 End If If (k >= 97 And k <= 122) Then a(k - 96) = a(k - 96) + 1 End If Next max = 0 For m = 1 To 26 If max < a(m)

2、Then max = a(m) End If Next Text2 = max For m = 1 To 26 If a(m) = max Then l = m End If Next Text1 = Chr(l + 64)2,打印出菱形Private Sub Form_Click() For i = 1 To 5 For j = 1 To 6 - i Print " " Next j For j = 1 To 2 * i - 1 Print "*" Next j Print Next i For i = 1 To 4 For j = 1 To i +

3、1 Print " " Next j For j = 1 To (9 - 2 * i) Print "*" Next j Print Next iEnd Sub3,最长单词的长度,以该长度最后一次出现的单词是?Option Base 1Dim s As StringPrivate Sub Command1_Click() Open App.Path & "in5.dat" For Input As #1 s = Input(LOF(1), #1) Close #1End SubPrivate Sub Command2_Clic

4、k()'需考生编写帮我解释一下一下的代码:Dim s as stringFor i = 1 To Len(s) J = Asc(Mid(s, i, 1) Select Case J Case 48 To 57, 65 To 90, 97 To 122 Case Else Mid(s, i, 1) = "-" End Select Next i J = Len(s) - 1 For i = 1 To J If Mid(s, i, 1) = "-" And Mid(s, i + 1, 1) = "-" Then s = Left(

5、s, i) + Right(s, J - i) J = J - 1 i = i - 1 End If Next i s = Left(s, Len(s) - 1) R = Split(s, "-") B = R(0) For i = 1 To UBound(R) If Len(B) < Len(R(i) Then B = R(i) Next i For m = UBound(R) To 1 Step -1 If Len(B) = Len(R(m) Then Exit For End If Next Text1.Text = Len(B) Text2.Text = R(

6、m)End SubPrivate Sub Form_Unload(Cancel As Integer) Open App.Path & "out5.dat" For Output As #1 Print #1, Text1.Text, Text2.Text Close #1End Sub4,结构类型数据题目Private Type Recordtype myname As String * 10 a1 As Integer a2 As Integer a3 As IntegerEnd TypeDim maxval%, minval%Private Sub Comma

7、nd1_Click() '=考生应完成的程序(开始)= Dim s As Recordtype Open "in5.dat" For Random As #1 Len = Len(s) maxval = 0 minval = 300 For k = 1 To 20 Get #1, , s sumval = s.a1 + s.a2 + s.a3 If sumval > maxval Then maxval = sumval If sumval < minval Then minval = sumval Next k Close #1'=考生应完成的

8、程序(结束)=End SubPrivate Sub Command2_Click() Open App.Path & "out5.dat" For Output As #1 Print #1, maxval% Print #1, minval% Close #1End SubDim a(5, 40)Private Sub Command1_Click() Dim ch As String ch$ = "" Open App.Path & "in5.dat" For Input As #1 For i = 1 To 5

9、For j = 1 To 40 Input #1, a(i, j) ch = ch & a(i, j) & " " Next j ch = ch & Chr(13) & Chr(10) Next i Close #1 Text1.Text = chEnd SubPrivate Sub Command2_Click() '=考生编写的程序= For i = 1 To 5 Max = -100 Sum = 0 n = 0 For j = 1 To 40 If a(i, j) Mod 2 = 0 Then If Max < a(i, j) Then Max = a(i, j) Else Sum = Sum + a(i, j) n = n + 1 End If Next j Label1(i - 1).Caption = Max Text2(i - 1).Text = Int(Sum / n * 100) / 100 Next i '=End SubPrivate Sub Command3_Click() Open

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论