Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- int main() {
- setlocale(LC_ALL, "rus");
- int bufEnd, bufStart, startMax = 0;
- int endMax = 1;
- int n;
- char s[]="здесь вписать! по другому не умею\0";
- n = strlen(s);
- for (int i = 0; i <n + 1; i++){
- if (s[i] == ' ' || s[i] == '\0'){
- bufEnd = i;
- if (bufEnd - bufStart > endMax - startMax){
- startMax = bufStart;
- endMax = bufEnd;
- }
- bufStart = i + 1;
- }
- }
- for (int i = startMax; i < endMax; i++)
- cout << s[i];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement