早教吧作业答案频道 -->其他-->
VB.NET的题目哈随机产生20个大写字母,求出现次数最多的字母及出现次数,还有求出现次数为0的字母有哪些题目提示我使用数组元素作为计数器,输出结果用label显示.万谢
题目详情
VB.NET的题目哈 随机产生20个大写字母,求出现次数最多的字母及出现次数,还有求出现次数为0的字母有哪些
题目提示我使用数组元素作为计数器,输出结果用label显示.万谢
题目提示我使用数组元素作为计数器,输出结果用label显示.万谢
▼优质解答
答案和解析
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim g() As Char = a.ToCharArray
Dim MyRandom As New Random
Dim bs As String = ""
For i = 1 To 20
bs &= g(MyRandom.Next(0,g.GetUpperBound(0) + 1))
Next
Dim gs() As String = (From mt As Match In Regex.Matches(bs,"[A-Z]") Select mt.Value).ToArray
System.Array.Sort(gs)
gs = (From mt As Match In Regex.Matches(Join(gs,""),"([A-Z])\1*") Select mt.Value).ToArray
Dim g_len() As Integer
g_len = (From mt As Match In Regex.Matches(Join(gs,""),"([A-Z])\1*") Select mt.Length).ToArray ' 使用数组元素作为计数器g_len
System.Array.Sort(g_len,gs)
Label1.Text = "出现次数最多的字母:" & gs(gs.GetUpperBound(0)).Substring(0,1) & " 共出现" & g_len(g_len.GetUpperBound(0)) & "次" & vbCrLf & "没有出现的字母是:" & Join(a.Split(bs.ToCharArray),"")
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim g() As Char = a.ToCharArray
Dim MyRandom As New Random
Dim bs As String = ""
For i = 1 To 20
bs &= g(MyRandom.Next(0,g.GetUpperBound(0) + 1))
Next
Dim gs() As String = (From mt As Match In Regex.Matches(bs,"[A-Z]") Select mt.Value).ToArray
System.Array.Sort(gs)
gs = (From mt As Match In Regex.Matches(Join(gs,""),"([A-Z])\1*") Select mt.Value).ToArray
Dim g_len() As Integer
g_len = (From mt As Match In Regex.Matches(Join(gs,""),"([A-Z])\1*") Select mt.Length).ToArray ' 使用数组元素作为计数器g_len
System.Array.Sort(g_len,gs)
Label1.Text = "出现次数最多的字母:" & gs(gs.GetUpperBound(0)).Substring(0,1) & " 共出现" & g_len(g_len.GetUpperBound(0)) & "次" & vbCrLf & "没有出现的字母是:" & Join(a.Split(bs.ToCharArray),"")
End Sub
End Class
看了 VB.NET的题目哈随机产生...的网友还看了以下:
血糖浓度保持平衡对机体生命活动具有重要作用,如图为胰岛素作用机理模式图,请分析回答:(1)胰岛素降 2020-05-13 …
化学的那些元素自母,公式,怎样才能牢牢的记住?不容易搞混?化学的那些元素字母我是背一个忘一个,总记 2020-05-17 …
有没有在句子第一个字押韵的诗歌押韵,又作压韵,指在韵文的创作中,在某些句子的特定位置,都使用韵母相 2020-06-22 …
人在恐惧、紧张时,肾上腺髓质释放的某种激素会增多,该激素作用可使呼吸频率加快、心率加速.下列叙述错 2020-06-25 …
人在恐惧、紧张时,肾上腺髓质释放的某种激素会增多,该激素作用可使呼吸频率加快、心率加速.下列叙述错 2020-07-01 …
下列关于高等动物生命活动的调节,合理的一项是()A.促甲状腺激素释放激素作用于甲状腺,促使甲状腺产 2020-07-11 …
高等动物生命活动的调节,合理的一项是()A.促甲状腺激素释放激素作用于甲状腺,促使甲状腺产生甲状腺 2020-07-12 …
下列关于胡萝卜素作用的论述,错误的是[]A.胡萝卜素可以用来治疗缺乏维生素A而引起的各种疾病B.胡 2020-07-15 …
VB.NET的题目哈随机产生20个大写字母,求出现次数最多的字母及出现次数,还有求出现次数为0的字 2020-08-04 …
下列语句中,加点词语使用正确的一项是()A.从小到大,母亲一直是你的守护天使,当母亲需要你的时候,不 2020-12-28 …