Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string>
- using namespace std;
- int main()
- { int i, n, j, max;
- string s, s1;
- getline(cin,s);
- max = 0;
- n = 0;
- j = 0;
- for(i=0; i<=s.size(); i++)
- {
- if( n > max)
- {
- max = n;
- j = i ;
- }
- if(s[i]!= ' ')
- {
- n++;
- }
- else
- {
- n = 0;
- }
- }
- // s1 = s.substr(j-max, j);
- for(i = j-max; i<=j; i++)
- {
- cout<< s[i];
- }
- cout<< endl << max; //<<" " << j;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement