Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int i, n, j, max, k;
  10.     string s;
  11.     getline(cin,s);
  12.  
  13.   max = 0;
  14.     n = 0;
  15.     j = 0;
  16.     k = s.size();
  17.    
  18.     for(i = 0; i < k; i++)
  19.     {
  20.          if( s[i] != ' ' )
  21.         {
  22.            n++;
  23.         }
  24.         else
  25.         {
  26.          n = 0;
  27.         }
  28.  
  29.       if( n > max)
  30.         {
  31.            max = n;
  32.              j = i;
  33.         }
  34.     }
  35.  
  36.    
  37.     for( i = j - max; i <= j; i++ )
  38.     {
  39.         cout << s[i];
  40.     }
  41.     cout << endl << max; //<<" " << j;
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement