Advertisement
huutho_96

123456

Dec 24th, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. void main()
  6. {
  7. int i, max = 0, k = 0, t;
  8. char ten[31], s[31];
  9. gets_s(ten);
  10.  
  11. while (ten[0] == ' ') for (i = 0; i < strlen(ten); i++) ten[i] = ten[i + 1];
  12. while (ten[strlen(ten) - 1] == ' ') ten[strlen(ten) - 1] = '\0';
  13. 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];
  14. for (i = 0; i <= strlen(ten); i++)
  15. {
  16. if (ten[i] == ' ' || ten[i] == '\0')
  17. {
  18. if (max < i - k)
  19. {
  20. max = i - k;
  21. strncpy(s, ten + i - max, max);
  22. s[max] = '\0';
  23. }
  24. k = i;
  25. }
  26. }
  27. printf("%d\n", max);
  28. puts(s);
  29. puts(ten);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement