Advertisement
Guest User

Untitled

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