fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <list>
  4.  
  5. int main()
  6. {
  7. std::list<std::string> l;
  8. std::string str;
  9. do {
  10. std::cin >> str;
  11. if (str[str.length()-1] == '.') {
  12. std::string str2 = str.substr(0, str.length()-1);
  13. l.push_back(str2);
  14. } else {
  15. l.push_back(str);
  16. }
  17. } while (str[str.length()-1] != '.');
  18.  
  19. l.sort([](std::string &lhs, std::string &rhs)
  20. {
  21. return (lhs.length() > rhs.length()) ? true : false;
  22. });
  23.  
  24. // 輸出最長單字(在最前面)
  25. std::cout << std::endl << l.front() << std::endl;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 4364KB
stdin
I am a normal ptt user like everybody.
stdout
everybody