回文字符串:前后看都一样的字符串。 这是要判断的文件
When abba advereda often lottol peopleop interested applylpa hunters sendnes theeth resuer sameas position metiitme company will rececer xyxy resumes singnsi job opening therefore is very important qwerewq applicant must demonstrate that he or she is the best person someos joboaj hunterh read books or takeket courses to help themht make good firstrif impression These books andna courses are fullfu of advice and suggestions toto help job applicants preperp fororf their interviews successful applicants dresserd appropriately andan have clean and neateat appearance They takekat their resume listing of theireiht education and workrow experience with them toto the interview They also prepare listsil of questions about the job orro the companynpmoc
已给程序:
Option Base 1
Dim s As String
Private Sub Command1_Click()
Open App.Path & "\in3.dat" For Input As #1
s = Input(LOF(1), #1)
Close #1
End Sub
Private Sub Command2_Click()
Dim n As Integer, t As String, word_num As Integer
n = Len(s): t = ""
For i = 1 To n
c = Mid(s, i, 1)
If c" " Then
t = t + c
Else
If foundhuiwen(t) Then
word_num = word_num + 1
End If
t = ""
End If
Next i
Text1.Text = word_num
End Sub
'以下Function 过程用于判断字符串是否为回文
Function foundhuiwen(p As String)
'考生编写
If StrReverse(p) = p Then foundhuiwen = True
End Function
End Function
Private Sub Form_Unload(Cancel As Integer)
Open App.Path & "\out3.dat" For Output As #1
Print #1, Text1.Text
Close #1
End Sub
机试考这个 不过代码写了几行 运行结果是109,不知道对不对啊,纠结中...
|