⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sentence.cpp

📁 读取文本文件的
💻 CPP
字号:
// Sentence.cpp: implementation of the CSentence class.
//
//////////////////////////////////////////////////////////////////////

#include "..\headfile\Sentence.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSentence::CSentence()
{

}

CSentence::~CSentence()
{

}

CSentence::CSentence(const string &sentenceStr, int index)
{
	m_SentenceIndex = index;

	int iCurrentPos = 0;
	string Str;
	while(1)
	{
		unsigned int iPeriodPos = sentenceStr.find_first_of( ',', iCurrentPos  );
		unsigned int iExclamationPos = sentenceStr.find_first_of( ';', iCurrentPos );
		unsigned int iQueryPos = sentenceStr.find_first_of( ' ', iCurrentPos );
		unsigned int iMinPos = __min( __min( iPeriodPos, iExclamationPos ), iQueryPos );
		
		Str = sentenceStr.substr( iCurrentPos, iMinPos - iCurrentPos );
		m_WordList.push_back(Str);

		iCurrentPos = iMinPos + 1;

		if (iMinPos > sentenceStr.size())
		{
			break;
		}
	}
}

int CSentence::FindWord(const string &wordname, const int &secIndex)
{
	int i;
	int lenth = m_WordList.size();
	int num = 0;

	for (i=0; i<lenth; i++)
	{
		if (m_WordList[i] == wordname)
		{
			cout << secIndex+1<< '-' << m_SentenceIndex+1 << '-' << i+1 << endl;
			num++;
		}
	}

	return num; 
}

int CSentence::DisplayWord(map<string, int> &A)
{
	int i;
	int lenth = m_WordList.size();
	
	for (i=0; i<lenth; i++)
	{
		A[m_WordList[i]]++;
	}

	return SUCCESS;
}

int CSentence::Quit(void)
{
	m_WordList.clear();
	
	return SUCCESS;
}	

int CSentence::GetTotalWord(void)
{
	return m_WordList.size();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -