包含标点处理
#include
#include
#include
#include
int main()
{
std::string t, word, long_word;
getline(std::cin, t);
std::istringstream iss(t);
while (iss >> word)
{
std::string result;
std::remove_copy_if(word.begin(), word.end(),
std::back_inserter(result),
ispunct);
if (result.length() > long_word.length())
{
long_word = result;
}
}
std::cout << long_word << std::endl;
getchar();
return 0;
}
#include
#include
using namespace std;
int main() {
string word,longWord;
cout << "请输入英文句子,按ctrl+z后按下回车结束输入:\n";
while (cin >> word) {
if (word.length() > longWord.length())
longWord=word;
}
cout << "最长单词是"<return 0;
}