Advertisement
Spocoman

06. The Signal and the Noise

Oct 30th, 2023
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string str, num;
  8.     getline(cin, str);
  9.    
  10.     int maxNumber = -2147483647;
  11.  
  12.     for (int i = 0; i < str.length(); i++) {
  13.         if (str[i] == ' ') {
  14.             if (num != "" && stoi(num) > maxNumber) {
  15.                 maxNumber = stoi(num);
  16.             }
  17.             num = "";
  18.         }
  19.         else if (isdigit(str[i])) {
  20.             num += str[i];
  21.         }
  22.     }
  23.  
  24.     cout << maxNumber << endl;
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement