关于网友提出的“ C++实现从键盘输入一段文字(中文)后,对其中某个词语次数统计”问题疑问,本网通过在网上对“ C++实现从键盘输入一段文字(中文)后,对其中某个词语次数统计”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: C++实现从键盘输入一段文字(中文)后,对其中某个词语次数统计
描述: 各位高手帮帮忙,是输入的中文,最好输入后保存在一个文本文件中,给我一个完整的程序,尽量语言简单点,我学的比较基础
解决方案1: 这个问题没有说清,输入一句话如何划分词呢?底下程序使用空格断开的!先将就着用吧!
#include
#include
#include
#include
#include
#include
解决方案2: 仅供参考,尽管是VB6
Private Sub Form_Load()
Dim sentence As String
Dim words As String
Dim WordApp As Object
sentence = "请对您的言行负责,并遵守中华人民共和国有关法律法规,尊重网上道德。"
words = ""
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Add
WordApp.Selection.TypeText Text:=sentence
WordApp.Selection.HomeKey
Do
WordApp.Selection.MoveRight Unit:=2, Count:=1, Extend:=1
If WordApp.Selection.Text = vbCr Then Exit Do
words = words + WordApp.Selection.Text + vbCrLf
WordApp.Selection.MoveRight Unit:=1, Count:=1
Loop
WordApp.Quit SaveChanges:=0
Set WordApp = Nothing
MsgBox words
End
End Sub
以上介绍了“ C++实现从键盘输入一段文字(中文)后,对其中某个词语次数统计”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3647052.html