要求:
1 分离字符串里的大小写,数字,符号
代码如下:
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string s("ab2c3d7R4E6");
string numberics("0123456789");
string alphabetic("abcdefghijklmnopqrstuvwxyz");
string alphabetic1("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
string::size_type pos= 0;
// 查找数字 从s的 0 位置开始查找 npos表示string的末尾
cout<<"字符串:"<<s<<endl;
cout<<"-------数字--------"<<endl;
while((pos=s.find_first_of(numberics,pos))!=string::npo