fork(3) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5. #include <iterator>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. vector<string>words((istream_iterator<string>(cin)), istream_iterator<string>());
  11. swap(*min_element(words.begin(), words.end()), *max_element(words.begin(), words.end()));
  12. copy(words.begin(), words.end(), ostream_iterator<string>(cout, " "));
  13. }
Success #stdin #stdout 0.02s 2864KB
stdin
123 12 123 1234 123
stdout
123 1234 123 12 123