fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <algorithm>
  5. #include <sstream>
  6. #include <numeric>
  7.  
  8. using namespace std;
  9.  
  10. vector<string> split(const string& input, char delim)
  11. {
  12. vector<string> result;
  13. stringstream stream;
  14. stream.str(input);
  15. string token;
  16. while (getline(stream, token, delim)) {
  17. result.push_back(token);
  18. }
  19. return result;
  20. }
  21.  
  22. int main(){
  23. string input;
  24. getline(cin,input);
  25. vector<string> numbers = split(input,' ');
  26. sort(numbers.begin(),numbers.end());
  27. string smallest = accumulate(numbers.begin(),numbers.end(),string(""));
  28. string biggest = accumulate(numbers.rbegin(),numbers.rend(),string(""));
  29.  
  30. cout << " biggest is " << biggest << endl;
  31. cout << " smallest is " << smallest << endl;
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 15248KB
stdin
79 82 34 83 69
420 34 19 71 341
17 32 91 7 46
stdout
 biggest is 8382796934
 smallest is 3469798283