真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net回文數(shù) vb回文數(shù)代碼

求助vb.net題

其實(shí)我是看到懸賞分進(jìn)來的,這個,你先試著寫,碰到什么問題,再問吧,可以百度Hi我!!

創(chuàng)新互聯(lián)建站主要從事網(wǎng)站設(shè)計制作、成都網(wǎng)站制作、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)耀州,10余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220

VB.NET 編程 關(guān)于回文數(shù)的題目。

在WinForm項(xiàng)目的窗體上添加一個按鈕和文本框,然后把下面的代碼粘貼上去就可以了。

Public Function lsH(ByVal n As String) As String

Dim s1 As String = ""

Dim s2 As String = ""

Dim i As Integer = 0

Dim j As Integer

If n.Length = 1 Then

Return ("是回文數(shù)")

Else

If Tell_JiOu(n.Length) = 1 Then

j = (n.Length + 1) / 2

s1 = Mid(n, 1, j)

Else

j = n.Length / 2 + 1

s1 = Mid(n, 1, j - 1)

End If

For i = n.Length To j Step -1

s2 = s2 + Mid(n, i, 1)

Next

If s1 = s2 Then

Return "是回文數(shù)"

Else

Return "不是回文數(shù)"

End If

End If

End Function

'判斷一個整數(shù)的奇偶

Public Function Tell_JiOu(ByVal k As Integer) As Integer

If k Mod 2 = 0 Then

Return 2

Else

Return 1

End If

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click

Button.Text = lsH(TextBox1.Text)

End Sub

VB.NET 編寫函數(shù)過程IsH(n) 判斷是否為回文數(shù)

你的i = Len(Str(a))會出問題。

If i 1 Then

Return True

End If

這個返回在if內(nèi)部,當(dāng)條件不滿足將導(dǎo)致函數(shù)無返回。

以下代碼僅供參考:

Function IsH(ByVal a As Long) As Boolean

Dim i As Long, j As Long, t As String

t = a.ToString

i = t.Length

Select Case i

Case 1

Return True

Case 2

If Mid(t, 1, 1) = Mid(t, 2, 1) Then Return True Else Return False

Case 3

If Mid(t, 1, 1) = Mid(t, 3, 1) Then Return True Else Return False

Case Else

For j = 1 To i \ 2

If Mid(t, j, 1) Mid(t, i - j + 1, 1) Then Return False

Next j

End Select

Return True

End Function

vb.net 回文數(shù)函數(shù)

判斷一個數(shù)是否為回文數(shù)嗎?

 

Private?Function?IsH(a?As?String)?As?Boolean

Dim?l?As?Integer

l?=?Len(a)

IsH?=?True

For?i?=?1?To?l?/?2

If?Mid(a,?i,?1)??Mid(a,?l?+?1?-?i,?1)?Then

IsH?=?False

Exit?For

End?If

Next?i

End?Function

用這個函數(shù)


本文標(biāo)題:vb.net回文數(shù) vb回文數(shù)代碼
當(dāng)前路徑:http://weahome.cn/article/doddcjc.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部