fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. std::string word;
  7. size_t small = 1000, large = 0;
  8.  
  9. while (std::cin >> word)
  10. {
  11. if (word == ".") {
  12. break;
  13. }
  14. else
  15. {
  16. if (word.size() > large) {
  17. large = word.size();
  18. }
  19.  
  20. if (word.size() < small) {
  21. small = word.size();
  22. }
  23. }
  24.  
  25. }
  26.  
  27. std::cout << "Largest: " << large << "\nSmallest: " << small << "\n";
  28. }
Success #stdin #stdout 0s 16064KB
stdin
Ra good boolor staa . dna
stdout
Largest: 6
Smallest: 2