1 / 12
文档名称:

英文单词统计工具.ppt

格式:ppt   大小:812KB   页数:12页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

英文单词统计工具.ppt

上传人:mh900965 2018/4/12 文件大小:812 KB

下载得到文件列表

英文单词统计工具.ppt

相关文档

文档介绍

文档介绍:英文单词统计工具
网络制作人:飘逸大陆
这是一个英文单词统计工具,可以使用VS2005以上的编译器编译, 这是一个控制台程序。 dos界面,但很实用。 下面是源程序代码

#include""
#include""
int main(){
string filename;
Gui::frame();
Gui::putLine("\t输入文件名:");
cin>>filename;
Word word(filename);
("");
Gui::exit("任务完成,程序将推出!!");
return 0;
}

#ifndef WORD_H
#define WORD_H
#include<map>
#include<string>
using namespace std;
class Word{
public:
Word(const string &filename);
void outToFile(const string&filename)const;
private:
map<string,int> words;
};
#endif

#ifndef GUI_H
#define GUI_H
#include<iostream>
using namespace std;
class Gui{
public:
static void frame();
static void exit(const string& content);
static void putLine(const string& content);
};
#endif

#include<string>
#include<>
#include""
void Gui::frame(){
cout<<"......应用程序启动......"<<endl;
}
void Gui::exit(const string& content){
putLine(content);
cout<<"按任意键退出...";
getch();
std::exit(1);
}
void Gui::putLine(const string &content){
cout<<content<<"...\n"<<endl;
}

#include<iostream>
#include<fstream>
#include<map>
#include""
#include""
Word::Word(const string& filename){
ifstream infile(());
if(!infile){
Gui::exit("当前文件夹不存在此文件,文件打开失败");
}
Gui::putLine("文件打开成功,文件处理中");
string word;
int count=0;
while(infile>>word){
if(word[0]>=0&&word[0]<=127){
int pos=()-1;
count=0;
while(pos>=0){
if(!((word[pos]>=65&&word[pos]<=90)||(word[pos]<=122&&word[pos]>=97))){
++count;
--pos;
}
else {
(()-count);
break;
}
}
if(pos<0)
continue;
count=0;
for(int i=0;i<()&&i>=0;++i){
if(!((word[i]>=65&&word[i]<=90)||(word[i]<=122&&word[i]>=97)))
++count;
else{
word=(count,()-count);
break;
}
}
if(()>0)
words[word]++;
}
}
();
Gui::putLine("文件处理成功");
}
void Word::outToFile(const string &filename)const{
Gui::putLine("正在生成文件");
ofstream outfile(());
map<string,int>::const_iterator p,end=();
for(p=word