Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <locale.h>
  4. #include <iostream>
  5.  
  6. int main()
  7. {
  8. char text[128][256];
  9. int n, maxLength = 0, indexMaxLengthString = 0;
  10.  
  11. puts("Введіть кількість рядків:");
  12. scanf("%d", &n);
  13. puts("Введіть текст:");
  14.  
  15. for (int i = 0; i <= n; i++)
  16. {
  17. gets(text[i]);
  18. if (strlen(text[i]) > maxLength)
  19. {
  20. maxLength = strlen(text[i]);
  21. indexMaxLengthString = i;
  22. }
  23. }
  24.  
  25. printf("The longest string: \n %s\n", text[indexMaxLengthString]);
  26. printf("have a %d words", maxLength);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement