C++ Primer课后练习9.47
2016-12-07 18:51
323 查看
9.47
#include #include using namespace std; int main(void) { string s1("ab2c3d7R4E6"); string s2("23746"), s3("abcdRE"); string::size_type pos = 0; while ((pos = s1.find_first_of(s2,pos)) != string::npos)//find_first_of找数字 { cout << "found number at index: " << pos << " element is " << s1[pos] << endl; ++pos; } pos = 0; while ((pos = s1.find_first_of(s3, pos)) != string::npos)//find_first_of找字母 { cout << "found letter at index: " << pos << " element is " << s1[pos] << endl; ++pos; } pos =0; while ((pos = s1.find_first_not_of(s2, pos)) != string::npos)//find_first_not_of找字母 { cout << "found letter at index: " << pos << " element is " << s1[pos] << endl; ++pos; } pos = 0; while ((pos = s1.find_first_not_of(s3, pos)) != string::npos)//find_first_not_of找字母 { cout << "found number at index: " << pos << " element is" << s1[pos] << endl; ++pos; } }
相关文章推荐
- C++ Primer课后练习10.20,10.21
- C++ Primer课后练习11.20,11.23,11.26,11.27,11.28,11.29,11.30,11.31,11.32
- C++ Primer 课后练习10.16,10.17,10.18,10.19
- C++ Primer 课后练习9.45
- C++ Primer 课后练习10.1,10.2,10.3,10.4,10.5,10.7,10.9
- C++ Primer课后练习10.34~10.37,10.42
- C++ primer 第五版 中文版 练习 9.47 个人code
- C++ Primer课后练习 9-46
- C++ Primer课后练习11.33-11.36
- c++ primer 课后练习 9.28
- C++ Primer 课后练习9.50
- C++ Primer课后练习10.22,10.23,10.24,10.25
- C++ Primer课后练习12.2
- C++ Primer课后练习9.52
- C++ Primer课后练习10.27,10.28
- C++ Primer课后练习10.22,10.24,10.25
- C++ Primer课后练习9.49
- C++ Primer课后练习10.29-10.33
- C++ Primer 第5版--练习9.47
- C++primer第5版课后练习习题答案9.47