Advertisement
Guest User

C

a guest
Nov 20th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<stdio.h>
  3. #include<Windows.h>
  4. #include<string.h>
  5.  
  6. int main()
  7. {
  8. char str[256], word[256],oneWord[30], inWord=0,maxWord=0,minWord=0, flag=0;
  9. int i, j, count = 0;
  10. while (printf("\n Enter text. For end - CTRL/Z: "), fgets(str, 255, stdin) != NULL)
  11. {
  12. inWord=0,maxWord=0,minWord=0, flag=0;
  13. i = 0, j = 0;
  14. for (i=0; str[i]; i++)
  15. {
  16. if (inWord == 0)
  17. {
  18.  
  19. if (str[i] != ' ' && str[i] != '\t' &&str[i] != '\n')
  20. {
  21. word[j++] = str[i];
  22. inWord = 1;
  23. }
  24. }
  25. else
  26. {
  27. if (str[i] != ' ' && str[i] != '\t' &&str[i] != '\n')
  28. word[j++] = str[i];
  29. else
  30. {
  31. inWord = 0;
  32. word[j] = '\0';
  33. if (j > maxWord)
  34. {maxWord = j; }
  35. else
  36. if(j<maxWord && flag==0)
  37. { minWord = j;
  38. flag=1;
  39. }
  40. else
  41. if(j<minWord && flag==1)
  42. {
  43. minWord=j;
  44.  
  45. }
  46.  
  47.  
  48. j = 0;
  49. printf("\n%s", word);
  50. count++;
  51.  
  52. }
  53.  
  54. }
  55. }
  56. printf("\n Max word is %d simbols, min word is %d simbols, number of all entered words is %d.\n", maxWord, minWord, count);
  57.  
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement