Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. int main() {
  4. setlocale(LC_ALL, "rus");
  5. int bufEnd, bufStart, startMax = 0;
  6. int endMax = 1;
  7. int n;
  8. char s[]="здесь вписать! по другому не умею\0";
  9. n = strlen(s);
  10.  
  11. for (int i = 0; i <n + 1; i++){
  12. if (s[i] == ' ' || s[i] == '\0'){
  13. bufEnd = i;
  14. if (bufEnd - bufStart > endMax - startMax){
  15. startMax = bufStart;
  16. endMax = bufEnd;
  17. }
  18. bufStart = i + 1;
  19. }
  20. }
  21. for (int i = startMax; i < endMax; i++)
  22. cout << s[i];
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement