有一段文本,存放在 CString 类 strText 里,文本的类似这样:Air and Space Exhibit Plays Off Real Missions
Washington Post - 25 minutes agoThey found life on Mars yesterday. But the fact that the "life" was some ultraviolet paint daubed on a styrofoam rock at the National Air and Space Museum explains why this story isn't on the front page.
从前有座山,山里有座庙!
NASA: Reality Surpasses Fantasy CBS News
On Mars and elsewhere, NASA science shines Florida Today(文本里有断行,有中文字符)需要得到
1、一个字符词典 strDictionary, 词典里存放上面文本中出现过的字符,按文本中出现的顺序排列,重复的字符被过滤掉,例如:
Air andSpceExhbtPlysOffRM2、需要一个函数快速检索文本 strText 中出现的每个字符在字典 strDictionary 中的位置索引怎么做最简洁?
Washington Post - 25 minutes agoThey found life on Mars yesterday. But the fact that the "life" was some ultraviolet paint daubed on a styrofoam rock at the National Air and Space Museum explains why this story isn't on the front page.
从前有座山,山里有座庙!
NASA: Reality Surpasses Fantasy CBS News
On Mars and elsewhere, NASA science shines Florida Today(文本里有断行,有中文字符)需要得到
1、一个字符词典 strDictionary, 词典里存放上面文本中出现过的字符,按文本中出现的顺序排列,重复的字符被过滤掉,例如:
Air andSpceExhbtPlysOffRM2、需要一个函数快速检索文本 strText 中出现的每个字符在字典 strDictionary 中的位置索引怎么做最简洁?
{
CMapStringToPtr StrMap;
int *p=new int;
*p=10;
StrMap.SetAt("bluebohe",p);
p=new int;
*p=11;
StrMap.SetAt("vcforever",p);
p=NULL;
POSITION pos=StrMap.GetStartPosition();
while(pos)
{
CString str;
StrMap.GetNextAssoc(pos,str,(void *&)p);
if(p!=NULL)
{
delete p;
p=NULL;
}
}
StrMap.RemoveAll();
}
——————————————————————————————#pragma warning(disable:4786)
#pragma warning(disable:4251)
#pragma warning(disable:4273)#include <map>
using namespace std;struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
}; {
map<const char*, int, ltstr> months;
months["january"] = 31;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
months["may"] = 31;
months["june"] = 30;
months["july"] = 31;
months["august"] = 31;
months["september"] = 30;
months["october"] = 31;
months["november"] = 30;
months["december"] = 31;
map<const char*, int, ltstr>::size_type st = months.size();
int i=months["january"];
i=months["february"];
months.clear();
}