完成代码如下,使用了stl库代码,具体函数使用请查阅详细资料
#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main()
{
string line;
//请在此处写下你的代码
regex email(R"(\w+@(\w+\.)+\w+)");
while (getline(cin, line)) {
smatch matches;
auto current = cbegin(line);
auto last = cend(line);
while (current != last) {
if (regex_search(current, last, matches, email)) {
ssub_match match = matches[0];
current = match.second;
cout << match.str() << endl;
} else {
break;
}
}
}
return 0;
}