//// ex9_47_2.cpp// Exercise 9.47//// Created by pezy on 12/5/14.//// @Brief Write a program that finds each numeric character// and then each alphabetic character in the string "ab2c3d7R4E6".// Write two versions of the program. The first should use find_first_of,// and the second find_first_not_of.// @Version find_first_not_of#include <string>#include <iostream>using std::string; using std::cout; using std::endl;int main(){string numbers{ "0123456789" };string alphabet{ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" };string str{ "ab2c3d7R4E6" };cout << "numeric characters: ";for (int pos = 0; (pos = str.find_first_not_of(alphabet, pos)) != string::npos; ++pos)cout << str[pos] << " ";cout << "\nalphabetic characters: ";for (int pos = 0; (pos = str.find_first_not_of(numbers, pos)) != string::npos; ++pos)cout << str[pos] << " ";cout << endl;return 0;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。