fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main() {
  5. std::string word1;
  6. std::string word2;
  7.  
  8. std::cin >> word1 >> word2;
  9.  
  10. while (word2 != "END") {
  11. std::cout << std::min(word1, word2) << std::endl;
  12. word1 = std::max(word1, word2);
  13. std::cin >> word2;
  14. }
  15. std::cout << word1 << std::endl;
  16. }
  17.  
Success #stdin #stdout 0s 4376KB
stdin
a
b
e
c
d
f
g
END
stdout
a
b
c
d
e
f
g