获取字符串中的连续字母

1 view
Skip to first unread message
Message has been deleted

bruc...@gmail.com

unread,
Mar 9, 2006, 10:59:57 PM3/9/06
to 星星爱CPP
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
cout<<"Enter a string:";
string sline;// = "&**I*&*)&am(*&*4573Semker579";
getline( cin, sline );

multiset<string> result;
{
string::const_iterator sline_end = sline.end();
for( string::const_iterator itor1=sline.begin(), itor2;
(itor1=find_if(itor1,sline_end,::isalpha)) != sline_end; itor1=itor2 )
{
itor2 = find_if( itor1, sline_end, not1(ptr_fun(::isalpha))
);
result.insert( string(itor1,itor2) );
}
}

cout<<"Result :"<<endl;
copy( result.begin(), result.end(),
ostream_iterator<string>(cout,"\n") );

return 0;
}

---

Reply all
Reply to author
Forward
0 new messages