#include #include#include#include#include
using namespacestd;#define MAX 2000
charpText[MAX];charch;
FILE*fp,*out;//单词类
classWords
{public:
Words(stringstr)
{
count=1;
word=str;
next=NULL;
}int count; //出现的次数
stringword;
Words*next;
};classWordList
{public:void AddWord(string word); //添加单词
bool WordExist(string word); //判断单词是否存在
void WordPrint(); //打印出现次数最多的前五个单词
int getLength(){ return length;}//单词链表长度
int getTotal(){ return total;} //输入单词总数
WordList();~WordList();private:
Words*first;
Words*last;intlength;inttotal;
};
WordList::WordList()
{
first=new Words(" ");
first->next=NULL;
last=first;
length=0;
total=0;
}