在VB.NET中X为 4,9,12,15,22,33,44,66,72,84,87,92,96,98,99 Y为6,8,12,16,24,31,68,71,73,74,81,93,94将XY合并在Z中并排序最后的结果为4,6,8,9,12,15,16,22,24,31,33,44,66,68,71,72,73,74,81,84,87,92,93,94,96,98,99

来源:学生作业帮助网 编辑:作业帮 时间:2024/12/01 15:06:34
在VB.NET中X为 4,9,12,15,22,33,44,66,72,84,87,92,96,98,99 Y为6,8,12,16,24,31,68,71,73,74,81,93,94将XY合并在Z中并排序最后的结果为4,6,8,9,12,15,16,22,24,31,33,44,66,68,71,72,73,74,81,84,87,92,93,94,96,98,99
xTkoV+G|lH&ZE19&o] u 떌dkmq Yӭ}$dq@80|aq b_8!/q½c>@[7=<ρ wNY轻_r9Ю7i3\QxgZdNa2iESQ,jd#9FYIPfsj*-Vլ(ь$*VYI- Ah[>K f:?/HH%r((\"d1Ld-$U}" R~ZP gYLP$MII˚CsXIy3mq k2_5$eNJTQ<7E%ar=Y.RG_&7GNAdh"a6<̥SƲ"*bHDƺbYϓ|]#:3 vDw)SXجԊM"X'H"a;E&~Oƽl\<wVvT掍bKA! t!+/jnۜՑJ[5e@].8>t`|3ixT/n\|X}Bt2{bdBDECҠm&.b,Fk87w8 ^{8]5V諷Fݖ .;

在VB.NET中X为 4,9,12,15,22,33,44,66,72,84,87,92,96,98,99 Y为6,8,12,16,24,31,68,71,73,74,81,93,94将XY合并在Z中并排序最后的结果为4,6,8,9,12,15,16,22,24,31,33,44,66,68,71,72,73,74,81,84,87,92,93,94,96,98,99
在VB.NET中X为 4,9,12,15,22,33,44,66,72,84,87,92,96,98,99 Y为6,8,12,16,24,31,68,71,73,74,81,93,94将X
Y合并在Z中并排序最后的结果为4,6,8,9,12,15,16,22,24,31,33,44,66,68,71,72,73,74,81,84,87,92,93,94,96,98,99

在VB.NET中X为 4,9,12,15,22,33,44,66,72,84,87,92,96,98,99 Y为6,8,12,16,24,31,68,71,73,74,81,93,94将XY合并在Z中并排序最后的结果为4,6,8,9,12,15,16,22,24,31,33,44,66,68,71,72,73,74,81,84,87,92,93,94,96,98,99
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 x,y As String
x = "4,9,12,15,22,33,44,66,72,84,87,92,96,98,99"
y = "6,8,12,16,24,31,68,71,73,74,81,93,94"
Dim g() As Integer
g = Array.ConvertAll((x & "," & y).Split(","),New Converter(Of String,Integer)(AddressOf strToint))
System.Array.Sort(g)
Dim g_str() As String
g_str = Array.ConvertAll(g,New Converter(Of Integer,String)(AddressOf IntTostr))
Dim My_text As String = Join(g_str,",")
My_text = Regex.Replace(My_text,"\b(\w+),=\1)\b","") 'My_text是最终结果
End Sub
Public Shared Function strToint(ByVal bs As String)
Return CInt(bs)
End Function
Public Shared Function IntTostr(ByVal bs As Integer)
Return CStr(bs)
End Function
End Class
My_text是最终结果,重复的12被自动剔除了

用冒泡法啦,楼上的一写,谁还敢写冒泡法呀,不过要读的懂楼上的估计要冒泡

实际上VB.NET是用不到冒泡法,使用冒泡法基本是VB或转VB.NET,不过楼上的天书的确涉及到的方面太多,用了委托、VB.Net正则表达式,不过可能写错一句应该是My_text = Regex.Replace(My_text, "\b(\w+),(?=\1\b)", "") ,比如x = "4,9,12,15,22,33,44,66,72,84,87,92,96,98,99,999"就有可能误删...

全部展开

实际上VB.NET是用不到冒泡法,使用冒泡法基本是VB或转VB.NET,不过楼上的天书的确涉及到的方面太多,用了委托、VB.Net正则表达式,不过可能写错一句应该是My_text = Regex.Replace(My_text, "\b(\w+),(?=\1\b)", "") ,比如x = "4,9,12,15,22,33,44,66,72,84,87,92,96,98,99,999"就有可能误删除99,不过已经的确很精彩了

收起