Advertisement
Guest User

Untitled

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