/* Returns true if the given string contains digit(s), false otherwise */ bool contains_number(const string& str) { for (int k = 0; k < str.size(); k++) if (isdigit(str[k])) return true; return false; }
while (getline(ss, word, ' ')) & //read next word if (!contains_number(word)) //check if it contains a number { result.append(word); //add it to the resulting string if not result.append(" "); } return result; }
int main() { string str = "A fat 215 cat sat on 14rats and 8ate8 himself"; cout << "Original string:" << endl; cout << '\t' << str << endl;
cout << "A string with words containing numbers removed:" << endl; cout << '\t' << remove_words_with_numbers(str) << endl; return 0; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment