posts - 36,  comments - 28,  trackbacks - 0
如果你CString写的没错,而且创建的工程是控制台程序的话,要包含头文件afx.h
而且要加载mfc的库,设置办法:菜单栏里的project->settings->General选项卡下的Microsoft Foundation Classes:中选Use MFC,选静态或动态都可以,但是动态调用的话需要把MFC的动态库放在system32文件夹下。如果你CString写的没错,而且创建的工程是控制台程序的话,要包含头文件afx.h
而且要加载mfc的库,设置办法:菜单栏里的project->settings->General选项卡下的Microsoft Foundation Classes:中选Use MFC,选静态或动态都可以,但是动态调用的话需要把MFC的动态库放在system32文件夹下。
posted on 2009-11-18 17:05 Hali 阅读(4851) 评论(1)  编辑 收藏 引用

FeedBack:
# error C2065: 'map' : undeclared identifier
2011-01-07 10:14 | 中原(scimence@163.com)
C++统计各个单词出现的次数
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include <algorithm>
#include <functional>
using namespace std;
class wordcount
{
public:
string word;
int times;
wordcount(string s,int t)
{
word=s;
times=t;
}
int operator < (wordcount &w){return times<w.times;}
int operator > (wordcount &w){return times>w.times;}
};
int UDgreater ( wordcount elem1, wordcount elem2 )
{
return elem1 > elem2;
}
int main()
{
string s;
map<string,int> word;
vector<wordcount> word_count;
while(cin>>s)//ctrl+z结束
word[s]++;
for(map<string,int>::iterator itr=word.begin();itr!=word.end();itr++)
{
wordcount w(itr->first,itr->second);
word_count.push_back(w);
}
sort(word_count.begin(),word_count.end(),UDgreater);
for(vector<wordcount>::size_type i=0;i<word_count.size();i++)
{
cout<<word_count.word<<" "<<word_count.times<<endl;
}
return 0;
}


  回复  更多评论
  
只有注册用户登录后才能发表评论。

<2011年1月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345

常用链接

留言簿

随笔分类

随笔档案

休闲链接

学习链接

牛人博客

搜索

  •  

最新评论

阅读排行榜

评论排行榜