-
Notifications
You must be signed in to change notification settings - Fork 0
/
9_47_1.cpp
33 lines (29 loc) · 1002 Bytes
/
9_47_1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*************************************************************************
> File Name: 9_47_1.cpp
> Author: Jung
> Mail: jungzhang@xiyoulinux.org or zhanggen.jung@gmail.com
> Created Time: 2016年02月19日 星期五 17时42分31秒
> Description:
************************************************************************/
#include <iostream>
#include <cstdlib>
#include <string>
int main(int argc, char *argv[])
{
std::string str = "ab2c3d7R4E6";
std::string numbers("0123456789");
std::string alp("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM");
std::string::size_type pos = 0;
std::cout << "数字:";
while((pos = str.find_first_of(numbers, pos)) != std::string::npos) {
std::cout << pos++ << " ";
}
std::cout << std::endl;
pos = 0;
std::cout << "字母:";
while((pos = str.find_first_of(alp, pos)) != std::string::npos) {
std::cout << pos++ << " ";
}
std::cout << std::endl;
return EXIT_SUCCESS;
}