#include
#include
#include
#include
bool isdigit(char ch)
{
return (ch>=' '&&ch<='9');
}
using namespace std;
int main(void)
{
map words;
ifstream fin("a.txt");//a是要统计的文件
ofstream fout("b.txt");//结果存放在b中
string str;
int count=0;
if(!fin || !fout)
{
cout<<"open failed!"<<endl;
exit(1);
}
while(fin.good())
{
fin>>str;
words[str]++;
}
fin.close();
for(map<string,int>::iterator mit=words.begin();mit!=words.end();++mit)
{
if(!isdigit((mit->first)[0]))
{
fout<<mit->first<<": "<<mit->second<<endl;
++count;
}
}
fout<<"total: "<<count<<endl;
fout.close();
return 0;
}