问一个vb程序的运行结果

[复制链接]
查看11 | 回复2 | 2009-4-2 22:20:55 | 显示全部楼层 |阅读模式
回文字符串:前后看都一样的字符串。 这是要判断的文件
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,不知道对不对啊,纠结中...

回复

使用道具 举报

千问 | 2009-4-2 22:20:55 | 显示全部楼层
哈哈,你可能记错题目了,把另一个题目的结果109配到这个题目上来了!别太紧张,你做的完全正确,考完了就好好放松放松去吧,祝你走运!...
回复

使用道具 举报

千问 | 2009-4-2 22:20:55 | 显示全部楼层
程序没问题,正确结果是12,不是109,你的程序运行的结果也是12,不知你的109是怎么来的。...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行