Advertisement
Guest User

Untitled

a guest
Oct 6th, 2019
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cctype>
  4. #include <cstring>
  5. #include <sstream>
  6.  
  7. using namespace std;
  8.  
  9. string readString(){
  10. string line;
  11. getline(cin, line);
  12. return line;
  13. }
  14.  
  15. void findMaxValue(vector<string> Vec){
  16.  
  17. string currentString;
  18. string temp;
  19. int temporaryInteger = 0;
  20. int maxValue = INT_MIN;
  21. int len = Vec.size();
  22. for(int i = 0; i < len; ++i){
  23. currentString = Vec[i];
  24. int currentLen = currentString.size();
  25. for(int k = 0; k < currentLen; ++k){
  26. if(isdigit(currentString[k]) == true){
  27. temp += currentString[k];
  28. }
  29. }
  30.  
  31. temporaryInteger = stoi(temp);
  32. if(temporaryInteger > maxValue){
  33. maxValue = temporaryInteger;
  34. }
  35.  
  36. temporaryInteger = 0;
  37. temp = " ";
  38. }
  39.  
  40. cout << maxValue;
  41.  
  42. }
  43.  
  44.  
  45. int main()
  46. {
  47. string eachElement;
  48. string inputData;
  49. vector<string> input;
  50. inputData = readString();
  51. istringstream istr(inputData);
  52.  
  53. while(istr >> eachElement){
  54. input.push_back(eachElement);
  55. }
  56.  
  57. findMaxValue(input);
  58.  
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement