Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void main()
- {
- int i, max = 0, k = 0, t;
- char ten[31], s[31];
- gets_s(ten);
- while (ten[0] == ' ') for (i = 0; i < strlen(ten); i++) ten[i] = ten[i + 1];
- while (ten[strlen(ten) - 1] == ' ') ten[strlen(ten) - 1] = '\0';
- for (i = 0; i < strlen(ten); i++) if (ten[i] == ' ') while (ten[i + 1] == ' ') for (int j = i; j < strlen(ten); j++) ten[j] = ten[j + 1];
- for (i = 0; i <= strlen(ten); i++)
- {
- if (ten[i] == ' ' || ten[i] == '\0')
- {
- if (max < i - k)
- {
- max = i - k;
- strncpy(s, ten + i - max, max);
- s[max] = '\0';
- }
- k = i;
- }
- }
- printf("%d\n", max);
- puts(s);
- puts(ten);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement